You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "jayendra13 (via GitHub)" <gi...@apache.org> on 2026/03/10 16:59:02 UTC
Re: [I] Expr formatting missing parentheses [datafusion]
jayendra13 commented on issue #16054:
URL: https://github.com/apache/datafusion/issues/16054#issuecomment-4032997609
Hi @AndreaBozzo, I've been working on the same issue and took a slightly different approach — precedence-based parenthesization instead of unconditional wrapping.
The idea is to only add parentheses when the child operator has lower precedence than the parent, matching the logic already used by the Display impl for BinaryExpr (line 621). This
avoids unnecessary parens for same/higher precedence cases, which may help with the SLT failures you're seeing from optimize_projections.
For example, SELECT 1+2+3:
- Before: Int64(1) + Int64(2) + Int64(3) (already correct, no parens needed)
- Unconditional: (Int64(1) + Int64(2)) + Int64(3) (unnecessary parens, changes schema name)
- Precedence-based: Int64(1) + Int64(2) + Int64(3) (unchanged, no schema mismatch)
My branch is here: https://github.com/jayendra13/datafusion/tree/fix-schema-parens
Happy to collaborate or consolidate — let me know what you think.
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org