yaooqinn commented on code in PR #55506:
URL: https://github.com/apache/spark/pull/55506#discussion_r3130190569
##########
sql/core/src/test/scala/org/apache/spark/sql/execution/WholeStageCodegenSuite.scala:
##########
@@ -1030,6 +1030,52 @@ class WholeStageCodegenSuite extends QueryTest with
SharedSparkSession
}
}
+ test("SPARK-56032: FilterExec CSE emits all notNullPreds before guard
otherPred") {
+ // The CSE branch in FilterExec.doConsume emits every notNullPred upfront,
+ // before any otherPred. When `InferFiltersFromConstraints` adds a notNull
+ // check on a throw-capable expression (`IsNotNull(cast(s as int))`)
derived
+ // from a downstream join, that upfront evaluation fires on rows that the
+ // guard otherPred (`kind = 'numeric'`) would have rejected.
+ //
+ // Shape:
+ // WITH guarded AS (SELECT s FROM t WHERE kind = 'numeric'),
+ // derived AS (SELECT s, CAST(s AS INT) AS n FROM guarded),
+ // pairs AS (SELECT s, i FROM derived, idx WHERE i <= n)
+ // SELECT s, i FROM pairs
+ // Optimized filter:
+ // Filter(isnotnull(kind) AND kind = 'numeric' AND isnotnull(cast(s as
int)))
+ // The non-CSE path defers leftover notNullPreds to after the otherPreds,
+ // so the guard short-circuits before the cast runs.
Review Comment:
Consider reducing the comments here, e.g. the query example here and in
tests are basically identical?
--
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]