goutamadwant opened a new pull request, #23356: URL: https://github.com/apache/datafusion/pull/23356
## Which issue does this PR close? - Closes #16054. ## Rationale for this change Expression-derived display names could omit required parentheses for nested binary expressions. For example, `(1 + 2) * 3` could be displayed as `1 + 2 * 3`, which changes how the expression reads. Unary expressions with binary children had the same ambiguity, such as `NOT a = b` and unary negative over a binary expression. ## What changes are included in this PR? - Adds precedence-aware parenthesization for nested binary expressions in `SchemaDisplay`. - Applies the same parenthesization behavior to `SqlDisplay`. - Wraps binary children of unary `NOT` and unary negative expressions. - Adds focused unit coverage for `(1 + 2) * 3`, unary negative, and `NOT` with binary children. - Updates optimizer expected output where expression display names now include the corrected parentheses. ## Are these changes tested? - `cargo test -p datafusion-expr format_nested_binary_exprs_with_parentheses` - `cargo fmt --all` - `cargo test -p datafusion-expr` - `cargo test -p datafusion-optimizer` - `cargo clippy -p datafusion-expr -p datafusion-optimizer --all-targets --all-features -- -D warnings` - `git diff --check` ## Are there any user-facing changes? Yes. Expression-derived column names and SQL-like expression display output now include parentheses when needed to preserve the intended expression structure. -- 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]
