-
Notifications
You must be signed in to change notification settings - Fork 233
[AURON #2390] Preserve key-grouped partitions in native Iceberg scans #2391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
lyne7-sc
wants to merge
5
commits into
apache:master
Choose a base branch
from
lyne7-sc:fix/iceberg-key-grouped-partitioning
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
23b286a
test: cover key grouped native Iceberg scans
lyne7-sc 0a846f5
preserve key grouped partitioning for native Iceberg scans
lyne7-sc 36c2db3
simplify
lyne7-sc f9a73a7
test: fix Iceberg test for spark 3.4
lyne7-sc 776d798
ignore no-op DPP filters in key-grouped Iceberg scans
lyne7-sc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
runtimeFilters.nonEmptyand "runtime filtering actually happens" come apart in one case. Withspark.sql.optimizer.dynamicPartitionPruning.reuseBroadcastOnlyon (the default) and no reusable broadcast exchange to match,PlanDynamicPruningFilterssubstitutesDynamicPruningExpression(Literal.TrueLiteral)(v3.5.8,PlanDynamicPruningFilters.scala:78-80) — a filter that filters nothing. The AQE path does the same atPlanAdaptiveDynamicPruningFilters.scala:66-67, so this isn't limited to non-adaptive execution. Spark treats that value as absent in two places:doCanonicalizestrips it explicitly (BatchScanExec.scala:237-239), andfilteredPartitionstranslates runtime filters throughDataSourceV2Strategy.translateRuntimeFilterV2, which only matchesInSubqueryExec(DataSourceV2Strategy.scala:644-655) — soTrueLiteraltranslates to nothing,filteredPartitionsreturnspartitionsunfiltered, and the groups can't change.Where that lands:
select ... from fact f join dim d on f.p = d.p where d.x = 1, both tables Iceberg-partitioned onp, gets SPJ precisely because it's a sort-merge join (dim too large to broadcast). No BHJ ⇒ no reusable exchange ⇒ the DPP filter degrades toTrueLiteral⇒runtimeFilters.nonEmptyis true ⇒ the whole scan drops back to Spark, with zero runtime filtering having been performed.That costs native coverage rather than correctness — on master this query went native and returned wrong rows, so this is better either way. Is the wider guard deliberate, or would mirroring Spark's own
doCanonicalizepredicate be closer to the intent? One option, in case it's useful:(
Literalis already imported at:30; onlyDynamicPruningExpressionwould need adding.)Related: would a test pinning this branch help? Nothing in the suite reaches it today —
spark.sql.sources.v2.bucketing.enabledappears only in the two new tests, and every DPP test carries an explicit/*+ BROADCAST(d) */hint (:281-340, and also:357/:675), which forces the reusable exchange and a realInSubqueryExec. An SPJ query carrying runtime filters, asserting a clean fallback (right answer, noNativeIcebergTableScanExec, no exception), would pin the intended behavior — and if it turns out awkward to write becauseTrueLiteralmakes the fallback fire where you'd expect native execution, that's the answer to the question above.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the detailed explanation! That makes sense to me.
I updated the check to ignore
DynamicPruningExpression(Literal.TrueLiteral)while continuing to fall back to Spark for effective runtime filters.I also added coverage for both sides:
TrueLiteralruntime filter keeps the scan native and preservesKeyGroupedPartitioning.BatchScanExec.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix and the tests on both sides. Nothing further from me.