peter-toth commented on PR #58635:
URL: https://github.com/apache/spark/pull/58635#issuecomment-6825566268

   @pan3793, besides the review, I have a broader question. How urgent is this 
feature for you?
   
   I ask for two reasons.
   
   First, it collides a bit with #59866, which I hope to take out of draft this 
week. That PR adds per-partition Bloom filters for storage-partitioned joins on 
the heuristic path of `InjectRuntimeFilter`. With this PR, a `RUNTIME_FILTER` 
hint on such a join takes the hinted path. That path builds only the global 
filter, so the hint turns the per-partition one off. For the hint to reach the 
per-partition path, the settling here would have to rebuild those filters too. 
There are a few smaller points around the new batch order as well.
   
   Second, I have been thinking for a while about reworking DPP and the runtime 
Bloom filter into one feature. DPP is not that different from a Bloom filter 
based runtime filter. Both hold the join keys of the other side, one as an 
exact set and the other as a probabilistic one. So in most cases either could 
serve all three uses: partition pruning, row filtering and late materialization 
(storage filters). There are exceptions. For example, pruning by a partition 
transform like `bucket(N, id)` needs the exact values.
   
   Yet today they are two separate features that get in each other's way:
   - Each is added by its own logical rule.
   - Each rule guesses what physical planning will do, for example which join 
broadcasts or which DPP filter survives.
   - One can block the other on the same key (SPARK-60702).
   - Their subqueries evaluate a frozen copy of the creation side. The copy 
drifts from the join's side as pushdown and later rules change it, so it can 
read other rows than the join does (SPARK-60808, SPARK-60842).
   
   Much of the complexity of this PR comes from these guesses and copies:
   - the rule moved after the DPP pushdown and cleanup, so that it sees which 
DPP filters survive (finding 27 came from that move)
   - the repeatability analysis of the hinted side
   - the checks for keys that can fail (SPARK-60809)
   - the settling of the latest commit, which rebuilds the hinted filters when 
pushdown changes the hinted side
   - declining the hint when a DPP filter of another join prunes the hinted side
   
   I haven't worked out the details yet. These are the points I think such a 
rework would have to settle:
   - One rule for both, instead of two rules that guess each other's outcome.
   - Which filter to build. With a reusable broadcast, an IN-set built from it 
is almost free, whatever its size. Without one, maybe the size could decide 
between an IN-set and a Bloom filter.
   - What to do with the filter, decided at physical planning, as for DPP 
today: partition pruning, DSv2 runtime filtering, storage filters, row 
filtering, a per-partition filter under a storage-partitioned join, or nothing.
   - When a copy of the creation side is needed, how to keep it repeatable and 
fail open, so it can never fail the query or drop a row.
   - The safety rules in one place, for every path.
   - Compatibility: the physical expressions that Spark emits today stay, and 
the current rules stay behind a conf until the new path is proven.
   
   With that in place, I'd expect the hint to be small. It would ask for a 
filter from the hinted side and skip the cost heuristics, and correctness would 
come from the shared rules. So would it make sense to add the hint after such a 
rework?
   
   To be fair, this is not a short-term plan. I can't work on it now, since I'd 
like to finish the late materialization work first (#59866 and its follow-ups). 
A rework of this size would also need community agreement, probably an SPIP. So 
this is a question, not a request to stop. If the hint is needed soon, I'm 
happy to keep reviewing this PR.
   


-- 
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]

Reply via email to