bert-beyondloops commented on issue #25329: URL: https://github.com/apache/datafusion/issues/25329#issuecomment-5695657749
Repro: a struct-returning function referenced both as a bare value (`arrow_field(a) IS NOT NULL`) and via `get_field`/`[...]` inside a **Filter** predicate is evaluated twice, even on the datafusion commit incorporating the fix: "evaluate struct-returning UDFs once across repeated field accesses", apache/datafusion#23691. PR #23691 / issue #23655 only regression-tests this pattern inside a Projection; the same pattern inside a **Filter** predicate is not covered. Steps to reproduce : CREATE TABLE arrow_field_filter_cse_test(a INT) AS VALUES (1), (2); EXPLAIN FORMAT TREE SELECT a FROM arrow_field_filter_cse_test WHERE CASE WHEN arrow_field(a) IS NOT NULL THEN arrow_field(a)['nullable'] IS NULL END; ``` +---------------+-------------------------------+ | plan_type | plan | +---------------+-------------------------------+ | physical_plan | ┌───────────────────────────┐ | | | │ FilterExec │ | | | │ -------------------- │ | | | │ predicate: │ | | | │ __common_expr_7 IS NOT │ | | | │ NULL AND │ | | | │ __datafusion_ │ | | | │ extracted_8 IS NULL │ | | | └─────────────┬─────────────┘ | | | ┌─────────────┴─────────────┐ | | | │ ProjectionExec │ | | | │ -------------------- │ | | | │ __common_expr_7: │ | | | │ arrow_field(a) │ | | | │ │ | | | │ __datafusion_extracted_8: │ | | | │ get_field(arrow_field(a), │ | | | │ nullable) │ | | | │ │ | | | │ a: a │ | | | └─────────────┬─────────────┘ | | | ┌─────────────┴─────────────┐ | | | │ DataSourceExec │ | | | │ -------------------- │ | | | │ bytes: 112 │ | | | │ format: memory │ | | | │ rows: 2 │ | | | └───────────────────────────┘ | | | | +---------------+-------------------------------+ ``` The __common_expr_7 expression is only referenced once in the actual filter. -- 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]
