8000 Processing unsupported SQL files formats its comments unintended way · Issue #691 · tconbeer/sqlfmt · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Processing unsupported SQL files formats its comments unintended way #691

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

Open
to-lz1 opened this issue Apr 19, 2025 · 0 comments
Open

Processing unsupported SQL files formats its comments unintended way #691

to-lz1 opened this issue Apr 19, 2025 · 0 comments

Comments

@to-lz1
Copy link
to-lz1 commented Apr 19, 2025

Describe the bug
When sqlfmt processes SQL files containing unsupported syntax,
such as create or replace table or alter table,
the indentation of SQL comments is removed.

To Reproduce

sample sql file:

alter table project_id.dataset.my_table
set options (
    -- sample comment
    description = 'This is a table with a description'
);

create or replace table project_id.dataset.my_table as
select
    -- sample comment
    col1, col2, col3,
from my_dataset.my_table
;

will be formatted as:

alter table project_id.dataset.my_table
set options (
-- sample comment
    description = 'This is a table with a description'
);

create or replace table project_id.dataset.my_table as
select
-- sample comment
    col1, col2, col3,
from my_dataset.my_table
;

Expected behavior
I have read issues like #300 and understand that certain SQL syntax is currently not supported.
However, I would expect the original formatting to be preserved when encountering
unsupported syntax, especially the indentation of comments.

Actual behavior
The indentation of SQL comments is removed.

Additional context
0.24.0 and later have this problem, 0.23.3 and earlier do not.

I took a look at the history and found that #650 may have triggered this issue.

However, this PR changes the parsing result itself for unsupported DDL statements.
Therefore, I am not sure whether this Pull Request should be reverted, or if it should be modified to handle formatting correctly under the current design.

I would be happy to submit a PR once a solution is decided upon!

@to-lz1 to-lz1 changed the title Processing unsupported SQL files breaks its comments unintended way Processing unsupported SQL files formats its comments unintended way Apr 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant
0