Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make SQL strings generated from Exprs even "prettier" #10633

Closed
Tracked by #9494
alamb opened this issue May 23, 2024 · 2 comments
Closed
Tracked by #9494

Make SQL strings generated from Exprs even "prettier" #10633

alamb opened this issue May 23, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@alamb
Copy link
Contributor

alamb commented May 23, 2024

Is your feature request related to a problem or challenge?

Part of #9494

In #10573 @goldmedal made expressions from the DataFusion SQL unparser (aka expr --> String) nicer. However there are still certain cases where the rendering will err on the side of explicitness rather than (human readability()

For examoke, it 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. It could be nicer for generating SQL to read by humans

Describe the solution you'd like

If we want to make the generated SQL easier to read by humans / more succinct, these steps will have to be made "smarter".

Describe alternatives you've considered

  1. We'll have to add in the math rules (precidence) to avoid unneeded parentheses. These rules typically vary subtly between dialects.

  2. We could simply not do this item as well as it is likely hard to get right and maybe extra parens aren't all that bad 🤔

Additional context

No response

@MohamedAbdeen21
Copy link
Contributor

I think this can be closed now @alamb

@alamb
Copy link
Contributor Author

alamb commented Jul 12, 2024

Good call -- thanks @MohamedAbdeen21

@alamb alamb closed this as completed Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants