Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cpp/velox/compute/iceberg/IcebergWriter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class GlutenIcebergFileNameGenerator : public connector::hive::FileNameGenerator

std::pair<std::string, std::string> gen(
std::optional<uint32_t> bucketId,
const std::shared_ptr<const connector::hive::HiveInsertTableHandle> insertTableHandle,
const connector::hive::HiveInsertTableHandlePtr& insertTableHandle,
const connector::ConnectorQueryCtx& connectorQueryCtx,
uint32_t maxNumBuckets,
bool commitRequired) const override {
Expand Down
9 changes: 5 additions & 4 deletions cpp/velox/substrait/SubstraitToVeloxPlan.cc
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ std::shared_ptr<connector::hive::HiveInsertTableHandle> makeHiveInsertTableHandl
const std::vector<std::string>& partitionedBy,
const std::shared_ptr<connector::hive::HiveBucketProperty>& bucketProperty,
const std::shared_ptr<connector::hive::LocationHandle>& locationHandle,
const std::shared_ptr<dwio::common::WriterOptions>& writerOptions,
const std::unordered_map<std::string, std::string>& serdeParameters,
const dwio::common::FileFormat& tableStorageFormat = dwio::common::FileFormat::PARQUET,
const std::optional<common::CompressionKind>& compressionKind = {}) {
std::vector<std::shared_ptr<const connector::hive::HiveColumnHandle>> columnHandles;
Expand Down Expand Up @@ -783,11 +783,12 @@ std::shared_ptr<connector::hive::HiveInsertTableHandle> makeHiveInsertTableHandl
return std::make_shared<connector::hive::HiveInsertTableHandle>(
columnHandles,
locationHandle,
// The default of Velox's insert_existing_partitions_behavior, which Gluten does not set.
connector::hive::HiveConfig::InsertExistingPartitionsBehavior::kError,
tableStorageFormat,
bucketProperty,
compressionKind,
std::unordered_map<std::string, std::string>{},
writerOptions);
serdeParameters);
}

#ifdef GLUTEN_ENABLE_GPU
Expand Down Expand Up @@ -913,7 +914,7 @@ core::PlanNodePtr SubstraitToVeloxPlanConverter::toVeloxPlan(const ::substrait::
partitionedKey,
bucketProperty,
makeLocationHandle(writePath, fileName, fileFormat, compressionKind, bucketProperty != nullptr),
writerOptions,
makeParquetWriteSerdeParameters(writeConfs),
fileFormat,
compressionKind),
folly::F14FastSet<std::string>{});
Expand Down
26 changes: 26 additions & 0 deletions cpp/velox/utils/VeloxWriterUtils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,27 @@ using namespace facebook::velox::common;
namespace {
const int32_t kGzipWindowBits4k = 12;
const int32_t kZSTDDefaultCompressionLevel = 3;

// Marks the serde parameters of a write planned by Gluten. Other writes through the factory, such as Iceberg
// writes, must keep Velox's defaults.
const std::string kGlutenParquetWrite = "gluten.parquet.write";
} // namespace

std::unique_ptr<dwio::common::Writer> GlutenParquetWriterFactory::createWriter(
std::unique_ptr<dwio::common::FileSink> sink,
const std::shared_ptr<dwio::common::WriterOptions>& options) {
if (options->serdeParameters.count(kGlutenParquetWrite) > 0) {
auto sparkOptions = makeParquetWriteOption(
std::unordered_map<std::string, std::string>(options->serdeParameters.begin(), options->serdeParameters.end()));
if (options->formatSpecificOptions != nullptr) {
sparkOptions->formatSpecificOptions->merge(*options->formatSpecificOptions);
}
options->formatSpecificOptions = std::move(sparkOptions->formatSpecificOptions);
options->flushPolicyFactory = std::move(sparkOptions->flushPolicyFactory);
}
return ParquetWriterFactory::createWriter(std::move(sink), options);
}

std::shared_ptr<dwio::common::FormatSpecificOptions> GlutenParquetWriterFactory::createFormatOptions(
const config::ConfigBase& connectorConfig,
const config::ConfigBase& session) const {
Expand Down Expand Up @@ -156,4 +175,11 @@ std::shared_ptr<facebook::velox::dwio::common::WriterOptions> makeParquetWriteOp
return writeOption;
}

std::unordered_map<std::string, std::string> makeParquetWriteSerdeParameters(
const std::unordered_map<std::string, std::string>& sparkConfs) {
auto serdeParameters = sparkConfs;
serdeParameters[kGlutenParquetWrite] = "true";
return serdeParameters;
}

} // namespace gluten
13 changes: 13 additions & 0 deletions cpp/velox/utils/VeloxWriterUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ namespace gluten {

class GlutenParquetWriterFactory : public facebook::velox::parquet::ParquetWriterFactory {
public:
/// Applies the Spark write configs carried in the serde parameters of a write planned by Gluten (see
/// makeParquetWriteSerdeParameters) before creating the writer. Format options from the session and connector
/// configs take precedence over the Spark write configs.
std::unique_ptr<facebook::velox::dwio::common::Writer> createWriter(
std::unique_ptr<facebook::velox::dwio::common::FileSink> sink,
const std::shared_ptr<facebook::velox::dwio::common::WriterOptions>& options) override;

std::shared_ptr<facebook::velox::dwio::common::FormatSpecificOptions> createFormatOptions(
const facebook::velox::config::ConfigBase& connectorConfig,
const facebook::velox::config::ConfigBase& session) const override;
Expand All @@ -33,4 +40,10 @@ class GlutenParquetWriterFactory : public facebook::velox::parquet::ParquetWrite
std::shared_ptr<facebook::velox::dwio::common::WriterOptions> makeParquetWriteOption(
const std::unordered_map<std::string, std::string>& sparkConfs);

/// Returns the serde parameters of a Hive insert table handle that carry 'sparkConfs' to
/// GlutenParquetWriterFactory. Velox's insert table handle has no writer options: they would not survive
/// serialization of the plan.
std::unordered_map<std::string, std::string> makeParquetWriteSerdeParameters(
const std::unordered_map<std::string, std::string>& sparkConfs);

} // namespace gluten
4 changes: 2 additions & 2 deletions ep/build-velox/src/get-velox.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ set -exu

CURRENT_DIR=$(cd "$(dirname "$BASH_SOURCE")"; pwd)
VELOX_REPO=https://github.com/IBM/velox.git
VELOX_BRANCH=dft-2026_11_10
VELOX_ENHANCED_BRANCH=ibm-2026_11_10
VELOX_BRANCH=dft-2026_11_19
VELOX_ENHANCED_BRANCH=ibm-2026_11_19
VELOX_HOME=""
RUN_SETUP_SCRIPT=ON
ENABLE_ENHANCED_FEATURES=OFF
Expand Down
Loading