[SPARK-56414][SQL] Per-write options should take precedence over session config in Parquet and Avro#55280
Open
cloud-fan wants to merge 3 commits intoapache:masterfrom
Open
[SPARK-56414][SQL] Per-write options should take precedence over session config in Parquet and Avro#55280cloud-fan wants to merge 3 commits intoapache:masterfrom
cloud-fan wants to merge 3 commits intoapache:masterfrom
Conversation
…on config in Parquet and Avro Co-authored-by: Isaac
Co-authored-by: Isaac
Co-authored-by: Isaac
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
In
ParquetUtils.prepareWriteandAvroUtils.prepareWrite, several Hadoop configuration keys are unconditionally set from the session-levelSQLConf. Since write options are already merged into the Hadoop conf upstream viaSessionState.newHadoopConfWithOptions, these unconditional sets silently overwrite any per-write options the user provided.This PR introduces a shared
DataSourceUtils.setConfIfAbsentutility that only sets a key fromSQLConfif it is not already present in the conf, allowing per-write options to take precedence.Parquet keys fixed:
spark.sql.parquet.writeLegacyFormatspark.sql.parquet.outputTimestampTypespark.sql.parquet.fieldId.write.enabledspark.sql.legacy.parquet.nanosAsLongspark.sql.parquet.annotateVariantLogicalTypeAvro keys fixed:
avro.output.codec.zstd.bufferpool)avro.mapred.<codec>.level)Why are the changes needed?
Per-write options (passed via
DataFrameWriter.option()) should take precedence over session-level SQLConf defaults. This is already the case for compression codecs in both Parquet and Avro, but other write configuration keys had their per-write values silently overwritten. For example, settingspark.sql.parquet.outputTimestampTypeas a write option had no effect becauseprepareWritealways replaced it with the session config value.Does this PR introduce any user-facing change?
Yes. Per-write options for the listed keys now take effect instead of being silently ignored. Previously, only the session-level SQLConf value was used regardless of what was passed as a write option.
How was this patch tested?
Added an integration test in
ParquetEncodingSuitethat verifies per-write options override session config foroutputTimestampType(checks the physical Parquet type in the file footer) andwriterVersion(checks delta encoding is used with PARQUET_2_0).Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code (claude-opus-4-6)