peter-toth commented on PR #59866: URL: https://github.com/apache/spark/pull/59866#issuecomment-6915451831
Thank you for the review, @dongjoon-hyun. I force-pushed while the PR was back in draft. Your first five points led me to this redesign: - A per-partition bloom filter is now added only where the creation side is too big for a global one. So it never replaces a global bloom filter, and the two never compete. - The placeholder is a subquery expression, as `DynamicPruningSubquery` is. Its plan is the creation side. `MergeSubplans` merges the subqueries in that plan, but not the placeholder itself. - `InsertPerPartitionRuntimeFilterJoins` builds the semi joins only in the run on the whole query, after `MergeSubplans`. That run builds them in the subqueries too. - Each bloom filter is now sized at physical planning, over the partition keys the creation side reports. The points one by one: - [1] Each subquery's placeholder now waits for the run on the whole query. So `MergeSubplans` merges the two subplans, and `fact` is read once. The query in your comment reads `fact` twice with the conf off too, since the outer aggregate is the root of the plan. So the new test runs two scalar subqueries, and it fails on the previous head. - [2] `MergeSubplans` merges the scalar subqueries in the placeholder's plan, so `t` is read once. The test asserts that, and it fails on the previous head. - [3] A semi join is now added only where no global bloom filter fits. So no global bloom filter of its key runs anyway, and there is nothing to judge again. - [4] A semi join no longer has a global bloom filter to fall back on. A cartesian product or an outer broadcast nested loop join runs the semi join again with each read of its side, but it reads the application side's scan as often too. So the semi join stays there, and the known limits say so. - [5] The semi join no longer replaces a global check. Its per-row cost is in the known limits. - [6] The description and the code comment now speak of each pair of join keys. - [7], [8] A new test uses `UnboundIntBucketFunction`, and asserts that both partition-key projections stay in whole-stage codegen. The `days` test uses `UnboundPhysicalDaysFunction(LongDaysFunction)`. - [9], [10] The suite uses `InMemoryCatalystRuntimeFilterCatalog`. It also has `createIdTable` and `withoutGlobalBloomFilter`, and `perPartitionSemiJoin` goes through `semiJoinKey`. - [11] The two tests share `checkExistenceJoin`. - [12] `CollapseCodegenStages` asks `fallsBackToEval`. - [13] Both guards are gone. - [14] `QueryExecution.preparations` now gives `ChoosePerPartitionRuntimeFilters` the same `EnsureRequirements` it plans with, as the adaptive preparations do. - [15] `rightBloomFilter` is gone. Other changes since your review: - A pair of join keys gets a semi join only when neither side gets a bloom filter of the whole creation side. A semi join next to such a bloom filter would read both sides again. - `ChoosePerPartitionRuntimeFilters` starts from the plan without the semi joins, and adds them back one at a time. So a semi join that goes cannot make one that is free look costly. - When a semi join goes, the projection above it merges with the one below. So a DPP filter can still reuse a broadcast of that side. - `ChoosePerPartitionRuntimeFilters` judges every semi join it finds, also when the conf was turned off after optimization. - There is no per-partition bloom filter over a V2 scan with a pushed operation that does not work on each row by itself, such as a limit. The semi join's aggregate reads the scan again, and such a scan can return other rows. - The PR is rebased onto master, and the suite has the `@DataSourceV2Test` tag. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
