LukaZdravic commented on code in PR #60403:
URL: https://github.com/apache/spark/pull/60403#discussion_r4586094831
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala:
##########
@@ -2281,10 +2285,12 @@ object InferFiltersFromConstraints extends
Rule[LogicalPlan]
}
private def inferFilters(plan: LogicalPlan): LogicalPlan =
plan.transformWithPruning(
- _.containsAnyPattern(FILTER, JOIN)) {
+ _.containsAnyPattern(FILTER, JOIN, AS_OF_JOIN)) {
case filter @ Filter(condition, child) =>
+ val canAdd: Expression => Boolean =
+ if (filter.getTagValue(asOfInputFilterTag).isDefined) canBeAsOfFilter
else canBeFilter
Review Comment:
Thanks, confirmed with a run: with ANSI and the legacy flag on, the
correlated scalar and LATERAL cases failed with DIVIDE_BY_ZERO, and the LATERAL
NOT IN case ran two anti joins. The as-of case now skips a plan rooted at a
correlated Subquery, and under the legacy flag it adds only IS NOT NULL. I also
added a test for the uncorrelated LATERAL, which still runs the rule twice
(TODO in the code); it fails with DIVIDE_BY_ZERO without the IS NOT NULL limit.
--
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]