Repository navigation
[GLUTEN-13671][VL] Pass Spark's default for returnNullStructIfAllFieldsMissing to the native Parquet scan - #13672
Conversation
…dsMissing to the native Parquet scan
|
Run Gluten Clickhouse CI on x86 |
|
@zhouyuan @philo-he @jackylee-ch Can you please take a look whenever you get a moment. Thanks! |
|
Run Gluten Clickhouse CI on x86 |
|
Run Gluten Clickhouse CI on x86 |
|
Run Gluten Clickhouse CI on x86 |
|
Gentle ping @zhouyuan @philo-he @jackylee-ch Can you please take a look? Thanks! |
|
Run Gluten Clickhouse CI on x86 |
|
Run Gluten Clickhouse CI on x86 |
There was a problem hiding this comment.
🟢 Approval recommended
The change is narrowly scoped to version-dependent default propagation and explicit overrides, with corresponding integration and JVM test additions for the affected behavior.
No open issues 🎉
What changed in this PR
This PR aligns Velox Parquet scans with Spark’s version-dependent default for handling structs whose requested fields are all missing, while preserving explicit session settings.
Changes:
- Propagates the Spark 4.1+-specific default to native session configuration while retaining the legacy behavior on earlier versions.
- Adds an integration test covering missing struct fields and native scan offloading.
- Adds JVM-only tests for default propagation and explicit configuration precedence.
| File | Description |
|---|---|
| gluten-substrait/src/main/scala/org/apache/gluten/config/GlutenConfig.scala | Propagates Spark’s version-dependent Parquet null-struct default to native configurations while retaining session overrides. |
| backends-velox/src/test/scala/org/apache/gluten/execution/VeloxScanSuite.scala | Adds an integration test verifying native Parquet scan behavior for missing struct fields across Spark versions. |
| backends-velox/src/test/scala/org/apache/gluten/config/VeloxConfigSuite.scala | Tests default propagation and explicit session-configuration precedence without requiring a native backend. |
Review effort: Lite
What changes are proposed in this pull request?
Fixes #13671
Related to #11914 / #13398.
Since Spark 4.1 (SPARK-53535),
spark.sql.legacy.parquet.returnNullStructIfAllFieldsMissingdefaults tofalse.getNativeSessionConfonly passed the key to native when it was set in the session, andConfigExtractor.ccfalls back totrue. So with the default config, the Velox scan returned null for every struct whose requested fields are all missing from the file, where Spark only returns null for structs that are null in the file.This PR adds the key to the configs whose Spark default is passed to native when unset. The default is
falseon Spark 4.1+. On Spark 3.4–4.0 the config doesn't exist and Spark behaves as if it weretrue, sotrueis passed there, which is the native fallback that applied before. A value set in the session still takes precedence.How was this patch tested?
New test in
VeloxScanSuite: writes a struct column with a null row, reads it with a schema whose struct fields are all missing from the file, and leaves the config unset. On Spark 4.1+ it expects a non-null struct for the non-null rows. On earlier versions it expects null for every row. It also checks that the scan is offloaded.New JVM-only cases in
VeloxConfigSuite, which need no native backend. With the config unset,getNativeSessionConf("velox", ...)passesfalseon Spark 4.1+ andtrueon earlier versions. A value set in the session is passed through unchanged. They pass on Spark 4.1 and 3.5, and the first one fails without this change (None did not contain "false").backends-veloxcompiles, including test sources, and passes scalastyle with-Pspark-3.5and with-Pspark-4.1 -Pscala-2.13 -Pjava-17.spotless:applymakes no changes.The new
VeloxScanSuitetest wasn't run locally, because it needs a native build. CI runsVeloxScanSuiteon every supported Spark version, including 4.1 and 4.2.Checked by hand with Spark 4.1.1, the Gluten nightly bundle
gluten-velox-bundle-spark4.1_2.13-linux_aarch64-1.9.0-SNAPSHOTfrom 2026-11-18, and this PR'sGlutenConfigput ahead of the bundle on the classpath. The query is the repro in [VL] Spark 4.1+: native Parquet scan returns null structs by default when all requested struct fields are missing #13671; the scan is offloaded in every Gluten run:{"x":null}NULL{"x":null}NULLNULLNULL{"x":null}NULL{"x":null}trueNULLNULLNULLWas this patch authored or co-authored using generative AI tooling?
Co-authored by: Claude Sonnet 4.5