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

sqlfmt breaks query hints #639

Closed
wr-atlas opened this issue Nov 6, 2024 · 0 comments · Fixed by #647
Closed

sqlfmt breaks query hints #639

wr-atlas opened this issue Nov 6, 2024 · 0 comments · Fixed by #647
Labels
bug Something isn't working databricks

Comments

@wr-atlas
Copy link

wr-atlas commented Nov 6, 2024

Describe the bug
In some dialects (eg databricks) we can define query hints. These are defined as comments in the format /*+ some_hint */.

sqlfmt formats these comments as /* + some_hint */ (notice the extra space) which is invalid, causing the hint to be ignored on runtime.

To Reproduce
Example run from command line: echo "select /*+ some_hint */ * from table" | sqlfmt -

Expected behavior
The query hint should remain the same:

select  /*+ some_hint */
    *
from table

Actual behavior
This is what sqlfmt gives:

select  /* + some_hint */
    *
from table

I think the easiest solution would be to detect the "+" and ignore these comments when formatting.

Additional context
What is the output of sqlfmt --version?
sqlfmt, version 0.23.2

@tconbeer tconbeer added the bug Something isn't working label Nov 12, 2024
tconbeer added a commit that referenced this issue Nov 22, 2024
* fix: support databricks type hint comments

* chore: update changelog

* fix: add unit test for coverage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working databricks
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants