alamb opened a new issue, #10557: URL: https://github.com/apache/datafusion/issues/10557
### Is your feature request related to a problem or challenge? As @backkem says https://github.com/apache/datafusion/pull/10528#issuecomment-2116068547 on https://github.com/apache/datafusion/pull/10528 Currently, expressions from the DataFusion SQL unparser (aka expr --> String) are somewhat ugly For example the expression `col("a").eq(lit(5))` would be rendered as `a = 5` by most poeple if they did it manaully, but DataFusion's unparser currently renders it like `"a" = 5` (with extra quotes). DataFusion also puts in quotes to make the order of operations explicit -- so instead of `a < 5 AND b < 10` it would render `("a" < 5) AND ("b" < 10)` The current unparser is conservative and likely works well for when generating SQL for consumptions by other database systems. However, the SQL is not as nice for human consumption Here is another instance from the example https://github.com/apache/datafusion/blob/98647e842a85b768ea0cb0f8ccf1016636001abb/datafusion-examples/examples/plan_to_sql.rs#L50-L53 ### Describe the solution you'd like If we want to make the generated SQL easier to read by humans / more succint, these steps will have to be made "smarter". ### Describe alternatives you've considered Potential ideas: 1. We'll have to add in the math rules to avoid unneeded parentheses 2. (likely dialect specific) rules for determining of quoting is needed. Note that the latter likely involves listing out the reserved keywords for each dialect. ### Additional context _No response_ -- 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]
