LukaZdravic commented on code in PR #60403:
URL: https://github.com/apache/spark/pull/60403#discussion_r4586101632
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/internal/SQLConf.scala:
##########
@@ -1866,6 +1866,18 @@ object SQLConf {
.booleanConf
.createWithDefault(false)
+ val INFER_FILTERS_ACROSS_AS_OF_JOIN_ENABLED =
+ buildConf("spark.sql.optimizer.inferFiltersAcrossAsOfJoin.enabled")
+ .internal()
+ .doc("When true, the query optimizer infers filters for the inputs of an
AS-OF join from " +
+ "its ON condition and its other input, such as `q.k = 7` from `ON t.k
= q.k` and " +
+ "`t.k = 7`. When false, it infers no filter for the inputs of an AS-OF
join, while " +
+ "other joins keep their inferred filters.")
Review Comment:
Done with your wording, plus that only IS NOT NULL is added under the legacy
flag; the PR description line is fixed too.
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala:
##########
@@ -2315,6 +2321,32 @@ object InferFiltersFromConstraints extends
Rule[LogicalPlan]
case _ => join
}
+
+ // A right row that fails the ON condition is never the match of any left
row, so a filter
+ // that follows from the left constraints and the ON condition can drop it
before the join.
+ // An inner join also drops the left rows without a match, so its left
side gets one too.
+ case j: AsOfJoin if conf.inferFiltersAcrossAsOfJoinEnabled =>
+ val allConstraints = getAllConstraints(j.left, j.right, j.condition)
Review Comment:
Done, thanks!
--
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]