Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ class VeloxParquetWriterInjects extends VeloxFormatWriterInjects {
// i.e., compression, block size, block rows.
val sparkOptions = new mutable.HashMap[String, String]()
sparkOptions.put(SQLConf.PARQUET_COMPRESSION.key, compressionCodec)
sparkOptions.put(
SQLConf.PARQUET_WRITE_LEGACY_FORMAT.key,
SQLConf.get.writeLegacyParquetFormat.toString)
val blockSize = options.getOrElse(
GlutenConfig.PARQUET_BLOCK_SIZE,
GlutenConfig.get.columnarParquetWriteBlockSize.toString)
Expand Down
8 changes: 8 additions & 0 deletions cpp/core/config/GlutenConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ const std::string kParquetWriterVersion = "parquet.writer.version";

const std::string kParquetCompressionCodec = "spark.sql.parquet.compression.codec";

/// Spark `spark.sql.parquet.writeLegacyFormat` (passed from the JVM as "true"/"false").
/// Used in VeloxWriterUtils to set `WriterOptions::enableStoreDecimalAsInteger` (inverted).
/// Velox decimal storage when enableStoreDecimalAsInteger is:
/// - true (Spark legacy off / unset): INT32/INT64 for short DECIMAL precisions; higher precisions
/// use FIXED_LEN_BYTE_ARRAY.
/// - false (Spark legacy on): FIXED_LEN_BYTE_ARRAY for all DECIMAL precisions.
const std::string kParquetStoreDecimalAsInteger = "spark.sql.parquet.writeLegacyFormat";

const std::string kColumnarToRowMemoryThreshold = "spark.gluten.sql.columnarToRowMemoryThreshold";

const std::string kUGIUserName = "spark.gluten.ugi.username";
Expand Down
11 changes: 11 additions & 0 deletions cpp/velox/utils/VeloxWriterUtils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ std::unique_ptr<WriterOptions> makeParquetWriteOption(const std::unordered_map<s
}
auto writeOption = std::make_unique<WriterOptions>();
writeOption->parquetWriteTimestampUnit = TimestampPrecision::kMicroseconds /*micro*/;
bool writeLegacyParquetFormat = false;
if (auto it = sparkConfs.find(kParquetStoreDecimalAsInteger); it != sparkConfs.end()) {
writeLegacyParquetFormat = boost::iequals(it->second, "true");
}
// Maps spark.sql.parquet.writeLegacyFormat to Velox enableStoreDecimalAsInteger (inverted).
// Controls how DECIMAL values are stored by the Writer:
// - true (default when legacy format is off): store as integer using INT32/INT64 for short
// DECIMAL precisions; higher precisions use FIXED_LEN_BYTE_ARRAY.
// - false (when spark.sql.parquet.writeLegacyFormat is true): store as FIXED_LEN_BYTE_ARRAY
// regardless of precision (Spark legacy Parquet decimal layout).
writeOption->enableStoreDecimalAsInteger = !writeLegacyParquetFormat;
Comment thread
jackylee-ch marked this conversation as resolved.
auto compressionCodec = CompressionKind::CompressionKind_SNAPPY;
if (auto it = sparkConfs.find(kParquetCompressionCodec); it != sparkConfs.end()) {
auto compressionCodecStr = it->second;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,7 @@ object GlutenConfig extends ConfigRegistry {
DEBUG_ENABLED.key,
// datasource config
SPARK_SQL_PARQUET_COMPRESSION_CODEC,
SQLConf.PARQUET_WRITE_LEGACY_FORMAT.key,
// datasource config end
GlutenCoreConfig.COLUMNAR_OVERHEAD_SIZE_IN_BYTES.key,
GlutenCoreConfig.COLUMNAR_OFFHEAP_SIZE_IN_BYTES.key,
Expand Down
Loading