[SPARK-59068][4.3][SQL] Correct runtime filter attribute handling - #58412
[SPARK-59068][4.3][SQL] Correct runtime filter attribute handling#58412szehon-ho wants to merge 8 commits into
Conversation
|
@cloud-fan @dongjoon-hyun @sunchao @HeartSaVioR can you help review (this is minimal DSV2 API-facing backport for Spark 4.3 to prevent breaking change) |
sunchao
left a comment
There was a problem hiding this comment.
Rereviewed 51ee79a with five independent agents. The original Catalyst example is fixed and its regression test passed in CI. Two remaining findings are noted inline, both limited to the in-memory test connectors and established from source. No local Spark test suites or runtime reproductions were run.
|
Added the two follow-ups from cloud-fan's post-merge review of #58370:
The focused regression passes. |
|
hi @sunchao , can you take another look when you get a chance (for 4.3) ? Thanks! |
|
I reviewed this backport with a multi-agent review (8 finder angles, then a verification pass), cross-checking against Merge order / cross-branch sync1. [P2] The last commit pre-includes the still-open master follow-up #58439 ( 2. [P2] The fixture transform-semantics fixes have no master counterpart ( Production code (same code exists on master)3. [P2] A top-level struct root in 4. [P3] DPP and row-level paths bypass the new structured error ( Cleanup (same code exists on master; best fixed upstream, then re-backported)5. [P3] Generated-by: Claude Fable 5 |
|
Hi, @szehon-ho . It seems that we need to revisit |
|
Thanks for the detailed review. The merge-order concern is now resolved: #58439 landed in both master (6864fbb) and branch-4.x (91c3e7d). Both commits have the same patch ID as c845783 in this PR. The transform-semantics changes are limited to test fixtures. I propose handling their upstream synchronization separately rather than expanding this 4.3 backport. Items 3–8 likewise describe existing upstream behavior or cleanup and should be addressed upstream first if pursued. |
|
Follow-up review of c845783 against the latest Test fixtures (this PR)1. [P2] 2. [P3] The test name "transformed partition source cannot be declared fully pushed" implies a Spark-side guard that does not exist ( 3. [P3] 4. [P3] 5. [P3] ~40 unchanged lines re-indented in Interface docs (same text exists on master; best fixed upstream)6. [P3] Root-attribute eligibility is documented as a contract rather than current behavior ( |
dongjoon-hyun
left a comment
There was a problem hiding this comment.
To prevent any accidental merging, I'm simply blocking this PR because we need to fix master branch first before this PR as @szehon-ho agreed here #58412 (comment) .
|
I opened #58503 as the It addresses the upstream items before this 4.3 backport proceeds:
The focused Catalyst, V1/V2 DPP, and both row-level implementations pass, along with compilation, error-condition validation, scalastyle, and checkstyle. Once #58503 lands in |
|
Thank you, @szehon-ho . Please address the review comments on that PR. |
|
Thank you, @szehon-ho . I approved the followup. Please make this PR up-to-date to make it consistent across branches. |
c845783 to
9cc2d08
Compare
|
Updated this 4.3 backport to reflect all approved changes from #58503. What changed:
Validation completed:
|
…st fixtures ### What changes were proposed in this pull request? This follow-up addresses the upstream review findings from #58412 before its Spark 4.3 backport proceeds. It: - restricts the in-memory V1, V2, Catalyst, and row-level runtime-filtering fixtures to identity partition transforms while preserving the real partition-key ordinal; - requires every `fullyPushedFilterAttributes()` entry to be an exact entry in `filterAttributes()`; - reports invalid runtime-filter declarations consistently from DPP, row-level group filtering, and iterative pushdown paths; - clarifies that Spark currently tracks runtime-filter eligibility by root attribute; and - adds regressions for transformed partition sources and invalid fully-pushed declarations. ### Why are the changes needed? The test fixtures could advertise a transformed source column and then compare its source value directly with a transformed partition key. That could incorrectly remove a matching partition before the residual predicate was evaluated. Also, a scan could declare a top-level struct as fully pushed while only declaring one nested field as filterable. Because Spark tracks eligibility by root attribute, this could remove a required post-scan predicate. Invalid connector declarations could additionally surface different errors depending on the planning path. ### Does this PR introduce _any_ user-facing change? Yes, on the unreleased `master` branch. Invalid Catalyst runtime-filter scan declarations are now rejected consistently during planning. Correct connector declarations and released Spark behavior are unchanged. ### How was this patch tested? Tests were added for Catalyst runtime filtering, V1/V2 DPP, and both group-based and delta-based row-level operations. - `build/sbt catalyst/Test/compile sql/Test/compile` - `SPARK_GENERATE_GOLDEN_FILES=1 build/sbt 'core/testOnly *SparkThrowableSuite -- -t "Error conditions are correctly formatted"'` - `SPARK_LOCAL_IP=localhost build/sbt 'sql/testOnly *DataSourceV2CatalystRuntimeFilterSuite'` - Focused transformed-partition DPP tests in `DataSourceV2SQLSuiteV1Filter` and `DataSourceV2SQLSuiteV2Filter` - Focused non-identity partition transform tests in `GroupBasedRowLevelOperationCatalystRuntimeFilterSuite` and `DeltaBasedRowLevelOperationCatalystRuntimeFilterSuite` - `build/sbt catalyst/scalastyle sql/scalastyle catalyst/checkstyle` - `git diff --check` ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Codex with GPT-5 Closes #58503 from szehon-ho/codex/runtime-filter-review-followup. Authored-by: Szehon Ho <szehon.apache@gmail.com> Signed-off-by: Szehon Ho <szehon.apache@gmail.com>
…st fixtures ### What changes were proposed in this pull request? This follow-up addresses the upstream review findings from #58412 before its Spark 4.3 backport proceeds. It: - restricts the in-memory V1, V2, Catalyst, and row-level runtime-filtering fixtures to identity partition transforms while preserving the real partition-key ordinal; - requires every `fullyPushedFilterAttributes()` entry to be an exact entry in `filterAttributes()`; - reports invalid runtime-filter declarations consistently from DPP, row-level group filtering, and iterative pushdown paths; - clarifies that Spark currently tracks runtime-filter eligibility by root attribute; and - adds regressions for transformed partition sources and invalid fully-pushed declarations. ### Why are the changes needed? The test fixtures could advertise a transformed source column and then compare its source value directly with a transformed partition key. That could incorrectly remove a matching partition before the residual predicate was evaluated. Also, a scan could declare a top-level struct as fully pushed while only declaring one nested field as filterable. Because Spark tracks eligibility by root attribute, this could remove a required post-scan predicate. Invalid connector declarations could additionally surface different errors depending on the planning path. ### Does this PR introduce _any_ user-facing change? Yes, on the unreleased `master` branch. Invalid Catalyst runtime-filter scan declarations are now rejected consistently during planning. Correct connector declarations and released Spark behavior are unchanged. ### How was this patch tested? Tests were added for Catalyst runtime filtering, V1/V2 DPP, and both group-based and delta-based row-level operations. - `build/sbt catalyst/Test/compile sql/Test/compile` - `SPARK_GENERATE_GOLDEN_FILES=1 build/sbt 'core/testOnly *SparkThrowableSuite -- -t "Error conditions are correctly formatted"'` - `SPARK_LOCAL_IP=localhost build/sbt 'sql/testOnly *DataSourceV2CatalystRuntimeFilterSuite'` - Focused transformed-partition DPP tests in `DataSourceV2SQLSuiteV1Filter` and `DataSourceV2SQLSuiteV2Filter` - Focused non-identity partition transform tests in `GroupBasedRowLevelOperationCatalystRuntimeFilterSuite` and `DeltaBasedRowLevelOperationCatalystRuntimeFilterSuite` - `build/sbt catalyst/scalastyle sql/scalastyle catalyst/checkstyle` - `git diff --check` ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Codex with GPT-5 Closes #58503 from szehon-ho/codex/runtime-filter-review-followup. Authored-by: Szehon Ho <szehon.apache@gmail.com> Signed-off-by: Szehon Ho <szehon.apache@gmail.com> (cherry picked from commit bce5ed1) Signed-off-by: Szehon Ho <szehon.apache@gmail.com>
|
looks like known failure: #58533 |
What changes were proposed in this pull request?
This PR backports the corrected runtime-filter attribute handling from #58370 to
branch-4.3.It:
filterAttributes()and preserves nested access in the pushed filter;fullyPushedFilterAttributes()limited to top-level attributes;This is a net backport. It adapts the final behavior to the 4.3 codebase without pulling in unrelated fixture refactoring from later branches.
Why are the changes needed?
branch-4.3contains the unreleasedSupportsRuntimeCatalystFilteringAPI, so this backport aligns its runtime-filter attribute behavior with the corrected implementation.Does this PR introduce any user-facing change?
Yes. Runtime-filtering scans may report nested references from ordinary
filterAttributes(). Nested references fromfullyPushedFilterAttributes()remain unsupported, and invalid fully-pushed attributes are rejected consistently during planning.For
SupportsRuntimeCatalystFiltering, this corrects behavior on the unreleased Spark 4.3 branch. Method signatures and binary compatibility are unchanged.How was this patch tested?
SPARK_GENERATE_GOLDEN_FILES=1 build/sbt 'core/testOnly *SparkThrowableSuite -- -t "Error conditions are correctly formatted"'build/sbt 'core/testOnly org.apache.spark.SparkThrowableSuite'build/sbt 'sql/testOnly org.apache.spark.sql.connector.DataSourceV2CatalystRuntimeFilterSuite'DataSourceV2SQLSuiteV1FilterandDataSourceV2SQLSuiteV2FilterGroupBasedRowLevelOperationCatalystRuntimeFilterSuiteDeltaBasedRowLevelOperationCatalystRuntimeFilterSuitecatalyst/scalastylesql/scalastylecatalyst/checkstylebuild/sbt 'sql/testOnly org.apache.spark.sql.connector.DataSourceV2CatalystRuntimeFilterSuite -- -z "missing fully pushed filter attribute"'Was this patch authored or co-authored using generative AI tooling?
Generated-by: Codex with GPT-5