LuciferYang commented on code in PR #60387:
URL: https://github.com/apache/spark/pull/60387#discussion_r4582929088
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/InjectRuntimeFilter.scala:
##########
@@ -244,6 +245,18 @@ object InjectRuntimeFilter extends Rule[LogicalPlan] with
PredicateHelper with J
targetKey,
currentPlan,
useMaterializedThreshold = false))
+ // A DSv2 scan can take a filter in fully and leave no `Filter` for it,
as a built-in file
+ // scan does with its partition filters. With no selective `Filter`
above the scan, its
+ // pushed filters count as such a `Filter` would, but only for a scan
whose pushed operations
+ // all work on each row by itself, since the bloom filter's subquery
reads it again. A pushed
+ // limit, for example, lets the source pick other rows on a second read.
+ case scan: DataSourceV2ScanRelation if scan.onlyRowWisePushdowns &&
Review Comment:
Update after merging master in a8816d768df: SPARK-60871 (9e81552e207) now
requires both keys to be binary stable in `extractBeneficialFilterCreatePlan`
for every creation side, so this PR no longer carries its own check. On master
too, that closes the gap on the selective-`Filter` path that my reply above
left open. The collated-key test stays, and now pins that a side found through
pushed filters stays behind that check.
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/InjectRuntimeFilter.scala:
##########
@@ -244,6 +245,18 @@ object InjectRuntimeFilter extends Rule[LogicalPlan] with
PredicateHelper with J
targetKey,
currentPlan,
useMaterializedThreshold = false))
+ // A DSv2 scan can take a filter in fully and leave no `Filter` for it,
as a built-in file
+ // scan does with its partition filters. With no selective `Filter`
above the scan, its
+ // pushed filters count as such a `Filter` would, but only for a scan
whose pushed operations
+ // all work on each row by itself, since the bloom filter's subquery
reads it again. A pushed
+ // limit, for example, lets the source pick other rows on a second read.
+ case scan: DataSourceV2ScanRelation if scan.onlyRowWisePushdowns &&
+ scan.pushedFilters.forall(isSimpleExpression) &&
+ scan.pushedFilters.exists(isLikelySelective) =>
+ Some(FilterCreationSide(
Review Comment:
Update in 476c97e8754: a side found through pushed filters is now taken only
if the checks that would reject it later accept it: `injectBloomFilter`'s size,
Python UDF and determinism checks, now in a shared `bloomFilterAggregate`, and
the check `creationSide` applies, with `canEvaluateAgain` for a key whose DPP
filter is dropped. Otherwise the search goes on to the other side of its join,
as on master. This replaces the last three sentences of my reply above: the
determinism check can reject such a side, through a non-deterministic key over
the scan. The SPARK-61173 test now has a pushed `RLIKE` on a key whose DPP
filter is dropped, and a non-deterministic key, and both get the bloom filter
on `f.part` from `bf2`. A materialized cache as the other side and a key
projection that can fail take the same path without a test of their own.
--
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]