Commit 809b7e7
[SPARK-59171][SQL] Make SchemaPruning idempotent after variant pushdown
### What changes were proposed in this pull request?
Run `SchemaPruning` after `PushVariantIntoScan` in the early scan pushdown batch. This removes variant reconstruction projections that become unnecessary during variant pushdown and allows the `Once` batch to reach the same plan on its first application.
Add a Parquet V1 regression test covering a query that reads `_metadata.file_path` while a VARIANT column is referenced below a nondeterministic filter.
Closes #57659. Tracks SPARK-59171.
### Why are the changes needed?
`PushVariantIntoScan` can make a variant reconstruction projection unnecessary after the earlier schema-pruning passes have completed. Reapplying the optimizer batch then removes that projection, so the first application is not a fixed point.
`RuleExecutor` checks `Once` batch idempotence only when `Utils.isTesting` is true. This causes affected Spark and Delta tests to fail, but production queries do not throw this error or return incorrect results. Outside test mode, the batch runs once and leaves a correct plan with a redundant reconstruction projection.
Running `SchemaPruning` once after variant pushdown makes the first application reach the stable plan. This change targets `master`; no backports are requested.
### Does this PR introduce _any_ user-facing change?
No. Production query results are unchanged. The patch removes a redundant reconstruction projection and prevents the testing-only `Once` batch idempotence failure.
### How was this patch tested?
The new regression test was confirmed to fail before the optimizer change and pass afterward.
The following tests and checks passed:
- `./build/sbt 'sql/testOnly org.apache.spark.sql.execution.datasources.parquet.ParquetV1SchemaPruningSuite -- -z "SPARK-59171"'`
- `./build/sbt 'sql/testOnly org.apache.spark.sql.execution.datasources.parquet.ParquetV1SchemaPruningSuite org.apache.spark.sql.execution.datasources.PushVariantIntoScanSuite org.apache.spark.sql.execution.datasources.PushVariantIntoScanVectorizedSuite'` (349 tests)
- `./build/sbt 'sql/scalastyle' 'sql/Test/scalastyle'`
- `git diff --check`
The full `./dev/run-tests` suite was not run locally.
### Was this patch authored or co-authored using generative AI tooling?
AI was used to review the code and understand the existing codebase.
This contribution is my original work, and I license it under the project's open source license.
Closes #57809 from goutamadwant/fix-schema-pruning-idempotence.
Authored-by: Goutam Adwant <workwithgoutam@gmail.com>
Signed-off-by: Uros Bojanic <221401595+uros-b@users.noreply.github.com>
(cherry picked from commit a5a9e7b)
Signed-off-by: Uros Bojanic <221401595+uros-b@users.noreply.github.com>1 parent 144e227 commit 809b7e7
2 files changed
Lines changed: 22 additions & 1 deletion
File tree
- sql/core/src
- main/scala/org/apache/spark/sql/execution
- test/scala/org/apache/spark/sql/execution/datasources/parquet
Lines changed: 4 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
57 | 60 | | |
58 | 61 | | |
59 | 62 | | |
| |||
Lines changed: 18 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
45 | 63 | | |
46 | 64 | | |
47 | 65 | | |
| |||
0 commit comments