james-willis commented on PR #27143: URL: https://github.com/apache/datafusion/pull/27143#issuecomment-6778981105
Thanks @jayzhan211, great catches. Addressed in 39697afaa. **Constant WHENs (~L1485):** took your diff with one tweak: if the simplified result is a literal, it takes the CASE's metadata, so `ELSE NULL` and `CASE WHEN true THEN 'x' ELSE g END` still fold instead of keeping the whole CASE. Anything else only simplifies if its metadata matches the CASE's. Your queries, plus an `nvl2` one, are in `metadata.slt`. You're right that a simplifier without a schema now errors on `CASE WHEN true THEN 1 ELSE col END`. I left it since `CASE WHEN false THEN col END` and `CASE WHEN c THEN col END` already error without a schema today. **AND/OR lowering (~L1555, L1613):** added your `case_branch_has_metadata` guard to both arms. The `NOT(CASE ...)` one can't be shown from SQL yet because physical NOT passes the metadata through (#27155), so `simplify_expr_case_keeps_field_metadata` covers it instead. Your `CASE WHEN p THEN f END` query is in `metadata.slt`. **Docs:** added the CASE entry to `to_field`. -- 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]
