Skip to content

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

@alamb

Description

@alamb

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions