Processing unsupported SQL files formats its comments unintended way · Issue #691 · tconbeer/sqlfmt · GitHub
More Web Proxy on the site http://driver.im/
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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!
The text was updated successfully, but these errors were encountered:
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
Describe the bug
When sqlfmt processes SQL files containing unsupported syntax,
such as
create or replace table
oralter table
,the indentation of SQL comments is removed.
To Reproduce
sample sql file:
will be formatted as:
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!
The text was updated successfully, but these errors were encountered: