pavankumargp6 commented on issue #16054:
URL: https://github.com/apache/datafusion/issues/16054#issuecomment-7281205309

   Hi! I'd like to take a look at this. The issue is that the SQL formatter 
(unparser) doesn't add parentheses in certain expressions where they're needed 
for precedence — e.g., `a + b * c` might be formatted without parentheses 
around `b * c`, changing the meaning.
   
   I've been reading the unparser code in `sql/unparser.rs` and the expression 
visitors. My plan is to:
   1. Identify the specific expression types where precedence handling is 
missing (binary ops, casts, etc.)
   2. Add proper precedence checks in the unparser so parentheses are inserted 
when needed
   3. Add test cases covering the edge cases mentioned in the issue
   
   Before I start:
   1. Is there a precedence table defined somewhere in the codebase I should 
use/reference?
   2. Are there existing tests for the unparser I can extend (e.g., in 
`sql/test.rs` or similar)?
   3. Should this fix also cover the `Expr::canonical_name` / display 
formatting, or just the SQL unparser?
   
   Thanks!
   


-- 
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]

Reply via email to