Skip to content

[GLUTEN-13671][VL] Pass Spark's default for returnNullStructIfAllFieldsMissing to the native Parquet scan - #13672

Merged
zhouyuan merged 6 commits into
apache:mainfrom
shivadarshan-devadiga:parquet-null-struct-default
Nov 23, 2026
Merged

zhouyuan merged 6 commits into
apache:mainfrom
shivadarshan-devadiga:parquet-null-struct-default

Conversation

@shivadarshan-devadiga

@shivadarshan-devadiga shivadarshan-devadiga commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

What changes are proposed in this pull request?

Fixes #13671

Related to #11914 / #13398.

Since Spark 4.1 (SPARK-53535), spark.sql.legacy.parquet.returnNullStructIfAllFieldsMissing defaults to false. getNativeSessionConf only passed the key to native when it was set in the session, and ConfigExtractor.cc falls back to true. 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 false on Spark 4.1+. On Spark 3.4–4.0 the config doesn't exist and Spark behaves as if it were true, so true is 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", ...) passes false on Spark 4.1+ and true on 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-velox compiles, including test sources, and passes scalastyle with -Pspark-3.5 and with -Pspark-4.1 -Pscala-2.13 -Pjava-17. spotless:apply makes no changes.

  • The new VeloxScanSuite test wasn't run locally, because it needs a native build. CI runs VeloxScanSuite on 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-SNAPSHOT from 2026-11-18, and this PR's GlutenConfig put 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:

    Run id 0 id 1 id 2
    Vanilla Spark, config unset {"x":null} NULL {"x":null}
    Gluten nightly, config unset NULL NULL NULL
    Gluten with this PR, config unset {"x":null} NULL {"x":null}
    Gluten with this PR, config true NULL NULL NULL

Was this patch authored or co-authored using generative AI tooling?

Co-authored by: Claude Sonnet 4.5

@github-actions github-actions Bot added CORE works for Gluten Core VELOX labels Nov 18, 2026
@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

@shivadarshan-devadiga

Copy link
Copy Markdown
Contributor Author

@zhouyuan @philo-he @jackylee-ch Can you please take a look whenever you get a moment. Thanks!

@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

@shivadarshan-devadiga

Copy link
Copy Markdown
Contributor Author

Gentle ping @zhouyuan @philo-he @jackylee-ch Can you please take a look? Thanks!

@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

@zhouyuan
zhouyuan requested a lite review from Copilot November 23, 2026 09:48

@zhouyuan zhouyuan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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

@zhouyuan
zhouyuan merged commit e73679b into apache:main Nov 23, 2026
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CORE works for Gluten Core VELOX

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[VL] Spark 4.1+: native Parquet scan returns null structs by default when all requested struct fields are missing

3 participants