dwsmith1983 commented on PR #5867: URL: https://github.com/apache/datafusion-comet/pull/5867#issuecomment-7083276457
This got a case wrong. With ANSI and subexpression elimination on, `SELECT * FROM t WHERE element_at(m, CAST(s AS DOUBLE) + CAST(s AS DOUBLE)) IS NULL` raised `CAST_INVALID_INPUT` on a row with a NULL `m`, where Spark returns the row. The decline exempted a subexpression the lookup itself repeats, since the dispatcher eliminates it and so does Spark. That holds in a projection, but Spark's whole-stage-codegen filter does not eliminate it (through 4.1), so Spark skips the key there. The same happened for a repeat in a later sort key, in a top-k ordering, and inside an `IF` branch, which `EquivalentExpressions` does not look into. The decline now compares what the dispatcher evaluates for every row with what Spark does: where Spark is certain to share the operator's subexpressions (a projection, shuffle keys, the top-k projection list) the lookup dispatches only when the two agree, and elsewhere any shared or repeated subexpression sends it to Spark. A self-repeating lookup in an aggregate's input falls back too, until #7586's per-operator scopes. `map_lookup_shared_subexpression_repeated.sql` covers these cases on Spark 3.5, 4.1 and 4.2. Since this changes what you approved, could you take another look? -- 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]
