fordN commented on PR #23691: URL: https://github.com/apache/datafusion/pull/23691#issuecomment-5622537264
I also ran into the need for this fix independently when using a UDF in a subquery and the struct fields are accessed in the outer query. ```sql SELECT decoded['from'], decoded['to'], MAX(decoded['value']) FROM (SELECT expensive_decode(a, b, c) AS decoded FROM t) GROUP BY 1, 2; ``` I've tested it rebased onto current `main` branch (with https://github.com/apache/datafusion/pull/24720 and https://github.com/apache/datafusion/pull/23459). All three of the guards appear to be needed and compose well. More specifically: - the aggregate shape I shared above, the issue's inline shape, and two no-GROUP-BY variants all evaluate the UDF once, in the logical plan and in `DataSourceExec` - `cargo test -p datafusion-optimizer extract_leaf` (55 tests) and `common_subexpr` (33) pass @tohuya6 if you are short on time I am happy to rebase and follow up to get this PR merged in, or open another PR that carries your commits with attribution. -- 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]
