Skip to content

Pretty SQL before sending to execution engine #2935

Closed

Description

@MikeWallis42

A small request I hope.
Would it be possible to use SQLGlot's pretty functionality before executing SQL statements?
It would be much easier to find syntax issues if it wasn't one long line.

Activity

  1. patricksurry commented on Jul 26, 2024

    @patricksurry

    had a similar comment for audits - it's great to be able to cut & paste sql for a failing audit, but would be even better if I could see pretty sql without an external tool. either by default or with sqlmesh audit --pretty or something.

  2. MikeWallis42 commented on Aug 14, 2024

    @MikeWallis42
    ContributorAuthor

    @izeigerman, please correct me if I'm wrong but would this be as simple to implement as changing this line from False to True?

    https://github.com/TobikoData/sqlmesh/blob/v0.117.0/sqlmesh/core/engine_adapter/base.py#L2037

    If so then I'd be happy to contribute this.

  3. izeigerman commented on Aug 14, 2024

    @izeigerman
    Collaborator

    @MikeWallis42 is the purpose of this to make the queries in logs prettier? Or some other place?

  4. izeigerman commented on Aug 14, 2024

    @izeigerman
    Collaborator

    I'm concerned that this will significantly increase the size of the payload and the IO overhead as a result. I'm open to making this configurable with this behavior being disabled by default.

  5. MikeWallis42 commented on Aug 15, 2024

    @MikeWallis42
    ContributorAuthor

    If I were to be really specific then this would be to better enable debugging and would typically be used during development more than in a production setting.
    As SQLGlot cannot and should not be validating the syntax of the SQL (apart from really basic things), it's often the case that bad SQL is written and run whilst developing.
    Finding the location of the bad SQL (from the execution engine) is typically easier when we can scan down and then across.
    At the moment all the issues are on line 1 and, sometimes, several thousand characters in.

    It might be that this would be configured against a specific gateway in the context of SQLMesh, at least in the way that I'm using it currently.

  6. tobymao commented on Aug 22, 2024

    @tobymao
    Contributor

    @MikeWallis42 are you planning to make a PR?

  7. MikeWallis42 commented on Aug 23, 2024

    @MikeWallis42
    ContributorAuthor

    I would love to have a go! I've made a start today

  8. tobymao commented on Aug 23, 2024

    @tobymao
    Contributor

    Great let us know if you need any help, you can ping us on slack.

  9. sungchun12 commented on Sep 5, 2024

    @sungchun12
    Contributor

    @MikeWallis42 looks like you're not the only one that cares about this: #3086 (comment)

    But looks like you don't want to see the pretty SQL rendered in the terminal, only in the query history for the engine executing the SQL. Is that correct?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ImprovementImproves existing functionality

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions