google / google-sql-syntax-ts

Apache License 2.0
7 stars 1 forks source link

General Issues with formatting result #3

Open mokshasoul opened 4 months ago

mokshasoul commented 4 months ago

Hi @Ekrekr, I've been following your work in dataform, and I was pleasantly surprised to see that this repository existed, as we wanted to understand how formatting works in the BQ UI.

I want to build a VSCode extension and tooling based on this, to standardize SQL formatting and have the same format between dataform, BQ UI and Airflow SQL.

The best formatter currently which is also compatible with jinja is SQLfluff, and produces very good results once configured.

One of our main problems with the current way formatting works is that the result for complex queries is completely unreadable for a human. Ideally the formatter would format based on some standards such as:

I would be in general interested in forking this and start hacking on it a bit whenever I have time, and/or provide some examples of how the output can be made more readable.

Lastly, I have a general question: would a change/suggestion in here be applied to the Monaco Editor under the BQ UI?

Thank you for taking your time to read this, and sorry for the long wall of text

Ekrekr commented 4 months ago

Hi Charis-Nicolas,

Great to hear that this is useful to you, particularly in regards to a potential VSCode extension! I totally agree that the formatting style could be improved, to follow general SQL standards.

Would a change/suggestion in here be applied to the Monaco Editor under the BQ UI?

Yes, the code here is what is used for formatting SQL in the UI. Right now it's just exported from internal, but I can propagate changes back.

Best, Elias

mokshasoul commented 4 months ago

Hey Elias, that's great to hear, I will have a talk internally if I can carve out some SAT time, and I'll get back to you in the coming weeks