Releases: tconbeer/sqlfmt
v0.24.0
sqlfmt CHANGELOG
All notable changes to this project will be documented in this file.
[Unreleased]
[0.24.0] - 2024-11-22
Formatting Changes and Bug Fixes
- sqlfmt no longer adds a space between the function name and parens for
filter()
,isnull()
, andrlike('foo', 'bar')
(but it also permitsfilter ()
,isnull ()
, andrlike ('foo')
to support dialects where those are operators, not function names) (#641, #478 - thank you @williamscs, @hongtron, and @chwiese!). - sqlfmt now supports Spark type-hinted numeric literals like
32y
and+3.2e6bd
and will not introduce a space between the digits and their type suffix (#640 - thank you @ShaneMazur!). - sqlfmt now supports Databricks query hint comments like
/*+ COALESCE(3) */
(#639 - thank you @wr-atlas!). - sqlfmt now no-ops instead of errors when encountering
create row access policy
statements withgrant
sub-statements (it also generally more robustly handles unsupported DDL) (#633).
[0.23.3] - 2024-11-12
Bug Fixes
- Fixes a bug where sqlfmt would split a comment containing a jinja tag into multiple lines, thus breaking the jinja tag (#628 - thank you for your issue and PR, @ryantimjohn!).
[0.23.2] - 2024-07-26
Bug Fixes
- Fixes a bug where complex python statements inside of jinja tags could cause unstable formatting (#600 - thank you @nenkie76!)
[0.23.1] - 2024-07-26
Bug Fixes
- Fixes a bug with the publish workflow that prevented a new package from being published to GHCR for 0.23.0
[0.23.0] - 2024-07-26
Formatting Changes and Bug Fixes
- sqlfmt will now parse unquoted reserved keywords as names if they are qualified by a period, e.g.,
foo.select
orfoo.case
(#599 - thank you @matthieucan!).
[0.22.0] - 2024-07-25
Formatting Changes and Bug Fixes
- DuckDB's
union [all] by name
is now supported (#611 - thank you @aersam!). interval
is now parsed as a word operator. Parenthesized expressions likeinterval (10) days
will maintain the space afterinterval
.- Fixed a bug where a line starting with an operator or word operator could be erroneously merged into a previous line (#602 - thank you @roveo!).
[0.21.4] - 2024-07-09
Formatting Changes and Bug Fixes
- Databricks
left anti
&right anti
joins are now supported.
[0.21.3] - 2024-04-25
Bug Fixes
- The Postgres operators for
(NOT) (I)LIKE
,~~
,~~*
,!~~
,!~~*
, are now supported (these use two tildes where the posix version of these operators use a single tilde) (#576 - thank you @tuckerrc!).
[0.21.2] - 2024-01-22
Bug Fixes
{% for %}...{% else %}...{% endfor %}
loops are now supported. Previously, a BracketError was raised if afor
loop included anelse
tag (#549 - thank you, @yassun7010!).
[0.21.1] - 2023-12-19
Bug Fixes
- Fixes a bug where extra indentation was added inside multiline jinja tags if those jinja tags contained a python multiline string (#536 - thank you @yassun7010!).
[0.21.0] - 2023-10-20
Bug Fixes
- Adds support for the
map<...>
type declaration syntax from Athena. (#500 - thank you for the issue and fix, @benjamin-awd!) - Fixes a bug where nested dicts inside jinja expressions (e.g.,
{{ {'a': {'b': 1}} }}
) could cause parsing errors (#471 - thank you @rparvathaneni-sc and @benjamin-awd!). This fix introduces a dependency on jinja2 > v3.0. - Fixes a bug in the lexing logic that prevented the walrus operator (
:=
) from being lexed as a single token (#502 - thank you @federico-hero!).
[0.20.0] - 2023-09-25
BREAKING CHANGES
- Drops support for Python 3.7. Please upgrade to Python 3.8 or higher.
Formatting Changes and Bug Fixes
any()
andall()
will no longer get spaces between the function name and the parenthesis, unless they are a part of alike any ()
orlike all ()
operator (#483 - thank you @damirbk!).- Snowflake's
//
comment markers are now parsed as comments and rewritten to--
on formatting (#468 - thank you @nilsonavp!). - DuckDB's
semi
,anti
,positional
, andasof
joins are now supported. (#482).
[0.19.2] - 2023-07-31
Bug Fixes
- Fixes a bug where
--exclude
would not follow symlinks when globbing
(#457 - thank you @jeancochrane!).
[0.19.1] - 2023-07-13
Bug Fixes
- Fixes a bug where
--fmt: off
comments could cause an error in formatting a file
(#447 - thank you @ramonvermeulen!). - Fixes a bug where some formatting changes were applied to sections of code in
--fmt: off
blocks. - Fixes a bug where comments inside of
--fmt: off
would still be formatted.
(#136).
[0.19.0] - 2023-06-08
Bug Fixes
- Relative
exclude
paths defined inpyproject.toml
files are now evaluated relative to the location of the file, not the current working directory.
Relative paths provided to the--exclude
option (or env var) are evaluated relative to the current working directory. Files and exclude paths
are now compared as resolved, absolute paths. (Fixes #431 - thank you @cmcnicoll!) - Fixes a bug where a comment like
{#-- comment --#}
would cause a false positive for the
comment safety check. (#434)
Formatting Changes
- sqlfmt now supports the
<=>
operator (#432 - thank you @kathykwon!)
[0.18.3] - 2023-05-31
Bug Fixes
- fixes a bug where multiple c-style comments (e.g.,
/* comment */
) on a single line would cause sqlfmt
to not include all comments in formatted output (#419 - thank you @aersam!)
Features
- adds a safety check to ensure comments are preserved in formatted output
[0.18.2] - 2023-05-31
- fixes a bug where specifying both relative and absolute paths would cause sqlfmt to crash (#426 - thank you for the issue and fix, @smcgivern!)
[0.18.1] - 2023-05-10
- fixes a bug when lexing
union distinct
tokens (#417 - thank you, @paschmaria!)
[0.18.0] - 2023-04-19
Formatting Changes
-
the contents of jinja blocks are now indented if the block wraps onto multiple rows (#403). This is now the proper sqlfmt style:
select some_field, {% for some_item in some_sequence %} some_function({{ some_item }}){% if not loop.last %}, {% endif %} {% endfor %}
While in this simple example the new style makes it less clear
thatsome_field
andsome_function
are at the
same SQL depth, the formatting of complex files with nested jinja blocks is much improved.
For example:{%- for col in cols -%} {%- if col.column.lower() not in remove | map( "lower" ) and col.column.lower() not in exclude | map("lower") -%} {% do include_cols.append(col) %} {%- endif %} {%- endfor %}
See also this discussion. Thank you
@dave-connors-3 and
@alrocar! -
sqlfmt now supports all Postgres frame clauses, not just those that start with
rows between
. (#404)
[0.17.1] - 2023-04-12
Bug Fixes
- fixed a bug where format-off tokens could cause sqlfmt to raise a bracket mismatch error (#395 - thank you, @AndrewLaneAtPowerSchool!).
[0.17.0] - 2023-02-24
Features
- sqlfmt now defaults to reading and writing files using the
utf-8
encoding. Previously, we used Python's default behavior of using the encoding from the host machine's locale. However, asutf-8
becomes a de-facto standard, this was causing issues for some Windows users, whose...
v0.23.3
sqlfmt CHANGELOG
All notable changes to this project will be documented in this file.
[Unreleased]
[0.23.3] - 2024-11-12
Bug Fixes
- Fixes a bug where sqlfmt would split a comment containing a jinja tag into multiple lines, thus breaking the jinja tag (#628 - thank you for your issue and PR, @ryantimjohn!).
[0.23.2] - 2024-07-26
Bug Fixes
- Fixes a bug where complex python statements inside of jinja tags could cause unstable formatting (#600 - thank you @nenkie76!)
[0.23.1] - 2024-07-26
Bug Fixes
- Fixes a bug with the publish workflow that prevented a new package from being published to GHCR for 0.23.0
[0.23.0] - 2024-07-26
Formatting Changes and Bug Fixes
- sqlfmt will now parse unquoted reserved keywords as names if they are qualified by a period, e.g.,
foo.select
orfoo.case
(#599 - thank you @matthieucan!).
[0.22.0] - 2024-07-25
Formatting Changes and Bug Fixes
- DuckDB's
union [all] by name
is now supported (#611 - thank you @aersam!). interval
is now parsed as a word operator. Parenthesized expressions likeinterval (10) days
will maintain the space afterinterval
.- Fixed a bug where a line starting with an operator or word operator could be erroneously merged into a previous line (#602 - thank you @roveo!).
[0.21.4] - 2024-07-09
Formatting Changes and Bug Fixes
- Databricks
left anti
&right anti
joins are now supported.
[0.21.3] - 2024-04-25
Bug Fixes
- The Postgres operators for
(NOT) (I)LIKE
,~~
,~~*
,!~~
,!~~*
, are now supported (these use two tildes where the posix version of these operators use a single tilde) (#576 - thank you @tuckerrc!).
[0.21.2] - 2024-01-22
Bug Fixes
{% for %}...{% else %}...{% endfor %}
loops are now supported. Previously, a BracketError was raised if afor
loop included anelse
tag (#549 - thank you, @yassun7010!).
[0.21.1] - 2023-12-19
Bug Fixes
- Fixes a bug where extra indentation was added inside multiline jinja tags if those jinja tags contained a python multiline string (#536 - thank you @yassun7010!).
[0.21.0] - 2023-10-20
Bug Fixes
- Adds support for the
map<...>
type declaration syntax from Athena. (#500 - thank you for the issue and fix, @benjamin-awd!) - Fixes a bug where nested dicts inside jinja expressions (e.g.,
{{ {'a': {'b': 1}} }}
) could cause parsing errors (#471 - thank you @rparvathaneni-sc and @benjamin-awd!). This fix introduces a dependency on jinja2 > v3.0. - Fixes a bug in the lexing logic that prevented the walrus operator (
:=
) from being lexed as a single token (#502 - thank you @federico-hero!).
[0.20.0] - 2023-09-25
BREAKING CHANGES
- Drops support for Python 3.7. Please upgrade to Python 3.8 or higher.
Formatting Changes and Bug Fixes
any()
andall()
will no longer get spaces between the function name and the parenthesis, unless they are a part of alike any ()
orlike all ()
operator (#483 - thank you @damirbk!).- Snowflake's
//
comment markers are now parsed as comments and rewritten to--
on formatting (#468 - thank you @nilsonavp!). - DuckDB's
semi
,anti
,positional
, andasof
joins are now supported. (#482).
[0.19.2] - 2023-07-31
Bug Fixes
- Fixes a bug where
--exclude
would not follow symlinks when globbing
(#457 - thank you @jeancochrane!).
[0.19.1] - 2023-07-13
Bug Fixes
- Fixes a bug where
--fmt: off
comments could cause an error in formatting a file
(#447 - thank you @ramonvermeulen!). - Fixes a bug where some formatting changes were applied to sections of code in
--fmt: off
blocks. - Fixes a bug where comments inside of
--fmt: off
would still be formatted.
(#136).
[0.19.0] - 2023-06-08
Bug Fixes
- Relative
exclude
paths defined inpyproject.toml
files are now evaluated relative to the location of the file, not the current working directory.
Relative paths provided to the--exclude
option (or env var) are evaluated relative to the current working directory. Files and exclude paths
are now compared as resolved, absolute paths. (Fixes #431 - thank you @cmcnicoll!) - Fixes a bug where a comment like
{#-- comment --#}
would cause a false positive for the
comment safety check. (#434)
Formatting Changes
- sqlfmt now supports the
<=>
operator (#432 - thank you @kathykwon!)
[0.18.3] - 2023-05-31
Bug Fixes
- fixes a bug where multiple c-style comments (e.g.,
/* comment */
) on a single line would cause sqlfmt
to not include all comments in formatted output (#419 - thank you @aersam!)
Features
- adds a safety check to ensure comments are preserved in formatted output
[0.18.2] - 2023-05-31
- fixes a bug where specifying both relative and absolute paths would cause sqlfmt to crash (#426 - thank you for the issue and fix, @smcgivern!)
[0.18.1] - 2023-05-10
- fixes a bug when lexing
union distinct
tokens (#417 - thank you, @paschmaria!)
[0.18.0] - 2023-04-19
Formatting Changes
-
the contents of jinja blocks are now indented if the block wraps onto multiple rows (#403). This is now the proper sqlfmt style:
select some_field, {% for some_item in some_sequence %} some_function({{ some_item }}){% if not loop.last %}, {% endif %} {% endfor %}
While in this simple example the new style makes it less clear
thatsome_field
andsome_function
are at the
same SQL depth, the formatting of complex files with nested jinja blocks is much improved.
For example:{%- for col in cols -%} {%- if col.column.lower() not in remove | map( "lower" ) and col.column.lower() not in exclude | map("lower") -%} {% do include_cols.append(col) %} {%- endif %} {%- endfor %}
See also this discussion. Thank you
@dave-connors-3 and
@alrocar! -
sqlfmt now supports all Postgres frame clauses, not just those that start with
rows between
. (#404)
[0.17.1] - 2023-04-12
Bug Fixes
- fixed a bug where format-off tokens could cause sqlfmt to raise a bracket mismatch error (#395 - thank you, @AndrewLaneAtPowerSchool!).
[0.17.0] - 2023-02-24
Features
- sqlfmt now defaults to reading and writing files using the
utf-8
encoding. Previously, we used Python's default behavior of using the encoding from the host machine's locale. However, asutf-8
becomes a de-facto standard, this was causing issues for some Windows users, whose locale was set to use older encodings. You can use the--encoding
option to specify a different encoding. Setting encoding toinherit
, e.g.,sqlfmt --encoding inherit foo.sql
will revert to the old behavior of using the host's locale. sqlfmt will detect and preserve a UTF BOM if it is present. If you specify--encoding utf-8-sig
, sqlfmt will always write a UTF-8 BOM in the formatted file. (#350, #381, #383 - thank you @profesia-company, @cmcnicoll, @aersam, and @ryanmeekins!)
[0.16.0] - 2023-01-27
Formatting Changes + Bug Fixes
- sqlfmt no longer merges lines that contain comments, unless the position of those comments can be preserved (#348 - thank you, @rileyschack and @IanEdington!). Accordingly, comments that are inline will stay inline, even if they are too long to fit.
- sqlfmt no longer merges together lines containing multiline jinja ...
v0.23.2
sqlfmt CHANGELOG
All notable changes to this project will be documented in this file.
[Unreleased]
[0.23.2] - 2024-07-26
Bug Fixes
- Fixes a bug where complex python statements inside of jinja tags could cause unstable formatting (#600 - thank you @nenkie76!)
[0.23.1] - 2024-07-26
Bug Fixes
- Fixes a bug with the publish workflow that prevented a new package from being published to GHCR for 0.23.0
[0.23.0] - 2024-07-26
Formatting Changes and Bug Fixes
- sqlfmt will now parse unquoted reserved keywords as names if they are qualified by a period, e.g.,
foo.select
orfoo.case
(#599 - thank you @matthieucan!).
[0.22.0] - 2024-07-25
Formatting Changes and Bug Fixes
- DuckDB's
union [all] by name
is now supported (#611 - thank you @aersam!). interval
is now parsed as a word operator. Parenthesized expressions likeinterval (10) days
will maintain the space afterinterval
.- Fixed a bug where a line starting with an operator or word operator could be erroneously merged into a previous line (#602 - thank you @roveo!).
[0.21.4] - 2024-07-09
Formatting Changes and Bug Fixes
- Databricks
left anti
&right anti
joins are now supported.
[0.21.3] - 2024-04-25
Bug Fixes
- The Postgres operators for
(NOT) (I)LIKE
,~~
,~~*
,!~~
,!~~*
, are now supported (these use two tildes where the posix version of these operators use a single tilde) (#576 - thank you @tuckerrc!).
[0.21.2] - 2024-01-22
Bug Fixes
{% for %}...{% else %}...{% endfor %}
loops are now supported. Previously, a BracketError was raised if afor
loop included anelse
tag (#549 - thank you, @yassun7010!).
[0.21.1] - 2023-12-19
Bug Fixes
- Fixes a bug where extra indentation was added inside multiline jinja tags if those jinja tags contained a python multiline string (#536 - thank you @yassun7010!).
[0.21.0] - 2023-10-20
Bug Fixes
- Adds support for the
map<...>
type declaration syntax from Athena. (#500 - thank you for the issue and fix, @benjamin-awd!) - Fixes a bug where nested dicts inside jinja expressions (e.g.,
{{ {'a': {'b': 1}} }}
) could cause parsing errors (#471 - thank you @rparvathaneni-sc and @benjamin-awd!). This fix introduces a dependency on jinja2 > v3.0. - Fixes a bug in the lexing logic that prevented the walrus operator (
:=
) from being lexed as a single token (#502 - thank you @federico-hero!).
[0.20.0] - 2023-09-25
BREAKING CHANGES
- Drops support for Python 3.7. Please upgrade to Python 3.8 or higher.
Formatting Changes and Bug Fixes
any()
andall()
will no longer get spaces between the function name and the parenthesis, unless they are a part of alike any ()
orlike all ()
operator (#483 - thank you @damirbk!).- Snowflake's
//
comment markers are now parsed as comments and rewritten to--
on formatting (#468 - thank you @nilsonavp!). - DuckDB's
semi
,anti
,positional
, andasof
joins are now supported. (#482).
[0.19.2] - 2023-07-31
Bug Fixes
- Fixes a bug where
--exclude
would not follow symlinks when globbing
(#457 - thank you @jeancochrane!).
[0.19.1] - 2023-07-13
Bug Fixes
- Fixes a bug where
--fmt: off
comments could cause an error in formatting a file
(#447 - thank you @ramonvermeulen!). - Fixes a bug where some formatting changes were applied to sections of code in
--fmt: off
blocks. - Fixes a bug where comments inside of
--fmt: off
would still be formatted.
(#136).
[0.19.0] - 2023-06-08
Bug Fixes
- Relative
exclude
paths defined inpyproject.toml
files are now evaluated relative to the location of the file, not the current working directory.
Relative paths provided to the--exclude
option (or env var) are evaluated relative to the current working directory. Files and exclude paths
are now compared as resolved, absolute paths. (Fixes #431 - thank you @cmcnicoll!) - Fixes a bug where a comment like
{#-- comment --#}
would cause a false positive for the
comment safety check. (#434)
Formatting Changes
- sqlfmt now supports the
<=>
operator (#432 - thank you @kathykwon!)
[0.18.3] - 2023-05-31
Bug Fixes
- fixes a bug where multiple c-style comments (e.g.,
/* comment */
) on a single line would cause sqlfmt
to not include all comments in formatted output (#419 - thank you @aersam!)
Features
- adds a safety check to ensure comments are preserved in formatted output
[0.18.2] - 2023-05-31
- fixes a bug where specifying both relative and absolute paths would cause sqlfmt to crash (#426 - thank you for the issue and fix, @smcgivern!)
[0.18.1] - 2023-05-10
- fixes a bug when lexing
union distinct
tokens (#417 - thank you, @paschmaria!)
[0.18.0] - 2023-04-19
Formatting Changes
-
the contents of jinja blocks are now indented if the block wraps onto multiple rows (#403). This is now the proper sqlfmt style:
select some_field, {% for some_item in some_sequence %} some_function({{ some_item }}){% if not loop.last %}, {% endif %} {% endfor %}
While in this simple example the new style makes it less clear
thatsome_field
andsome_function
are at the
same SQL depth, the formatting of complex files with nested jinja blocks is much improved.
For example:{%- for col in cols -%} {%- if col.column.lower() not in remove | map( "lower" ) and col.column.lower() not in exclude | map("lower") -%} {% do include_cols.append(col) %} {%- endif %} {%- endfor %}
See also this discussion. Thank you
@dave-connors-3 and
@alrocar! -
sqlfmt now supports all Postgres frame clauses, not just those that start with
rows between
. (#404)
[0.17.1] - 2023-04-12
Bug Fixes
- fixed a bug where format-off tokens could cause sqlfmt to raise a bracket mismatch error (#395 - thank you, @AndrewLaneAtPowerSchool!).
[0.17.0] - 2023-02-24
Features
- sqlfmt now defaults to reading and writing files using the
utf-8
encoding. Previously, we used Python's default behavior of using the encoding from the host machine's locale. However, asutf-8
becomes a de-facto standard, this was causing issues for some Windows users, whose locale was set to use older encodings. You can use the--encoding
option to specify a different encoding. Setting encoding toinherit
, e.g.,sqlfmt --encoding inherit foo.sql
will revert to the old behavior of using the host's locale. sqlfmt will detect and preserve a UTF BOM if it is present. If you specify--encoding utf-8-sig
, sqlfmt will always write a UTF-8 BOM in the formatted file. (#350, #381, #383 - thank you @profesia-company, @cmcnicoll, @aersam, and @ryanmeekins!)
[0.16.0] - 2023-01-27
Formatting Changes + Bug Fixes
- sqlfmt no longer merges lines that contain comments, unless the position of those comments can be preserved (#348 - thank you, @rileyschack and @IanEdington!). Accordingly, comments that are inline will stay inline, even if they are too long to fit.
- sqlfmt no longer merges together lines containing multiline jinja blocks unless those lines start with an operator or comma (#365 - thank you, @gavlt!).
- fixed a bug where adding a jinja end tag (e.g.,
{% endif %}
) to a line could cause bad formatting of everything on that line
[0.15....
v0.23.1
sqlfmt CHANGELOG
All notable changes to this project will be documented in this file.
[Unreleased]
[0.23.1] - 2024-07-26
Bug Fixes
- Fixes a bug with the publish workflow that prevented a new package from being published to GHCR for 0.23.0
[0.23.0] - 2024-07-26
Formatting Changes and Bug Fixes
- sqlfmt will now parse unquoted reserved keywords as names if they are qualified by a period, e.g.,
foo.select
orfoo.case
(#599 - thank you @matthieucan!).
[0.22.0] - 2024-07-25
Formatting Changes and Bug Fixes
- DuckDB's
union [all] by name
is now supported (#611 - thank you @aersam!). interval
is now parsed as a word operator. Parenthesized expressions likeinterval (10) days
will maintain the space afterinterval
.- Fixed a bug where a line starting with an operator or word operator could be erroneously merged into a previous line (#602 - thank you @roveo!).
[0.21.4] - 2024-07-09
Formatting Changes and Bug Fixes
- Databricks
left anti
&right anti
joins are now supported.
[0.21.3] - 2024-04-25
Bug Fixes
- The Postgres operators for
(NOT) (I)LIKE
,~~
,~~*
,!~~
,!~~*
, are now supported (these use two tildes where the posix version of these operators use a single tilde) (#576 - thank you @tuckerrc!).
[0.21.2] - 2024-01-22
Bug Fixes
{% for %}...{% else %}...{% endfor %}
loops are now supported. Previously, a BracketError was raised if afor
loop included anelse
tag (#549 - thank you, @yassun7010!).
[0.21.1] - 2023-12-19
Bug Fixes
- Fixes a bug where extra indentation was added inside multiline jinja tags if those jinja tags contained a python multiline string (#536 - thank you @yassun7010!).
[0.21.0] - 2023-10-20
Bug Fixes
- Adds support for the
map<...>
type declaration syntax from Athena. (#500 - thank you for the issue and fix, @benjamin-awd!) - Fixes a bug where nested dicts inside jinja expressions (e.g.,
{{ {'a': {'b': 1}} }}
) could cause parsing errors (#471 - thank you @rparvathaneni-sc and @benjamin-awd!). This fix introduces a dependency on jinja2 > v3.0. - Fixes a bug in the lexing logic that prevented the walrus operator (
:=
) from being lexed as a single token (#502 - thank you @federico-hero!).
[0.20.0] - 2023-09-25
BREAKING CHANGES
- Drops support for Python 3.7. Please upgrade to Python 3.8 or higher.
Formatting Changes and Bug Fixes
any()
andall()
will no longer get spaces between the function name and the parenthesis, unless they are a part of alike any ()
orlike all ()
operator (#483 - thank you @damirbk!).- Snowflake's
//
comment markers are now parsed as comments and rewritten to--
on formatting (#468 - thank you @nilsonavp!). - DuckDB's
semi
,anti
,positional
, andasof
joins are now supported. (#482).
[0.19.2] - 2023-07-31
Bug Fixes
- Fixes a bug where
--exclude
would not follow symlinks when globbing
(#457 - thank you @jeancochrane!).
[0.19.1] - 2023-07-13
Bug Fixes
- Fixes a bug where
--fmt: off
comments could cause an error in formatting a file
(#447 - thank you @ramonvermeulen!). - Fixes a bug where some formatting changes were applied to sections of code in
--fmt: off
blocks. - Fixes a bug where comments inside of
--fmt: off
would still be formatted.
(#136).
[0.19.0] - 2023-06-08
Bug Fixes
- Relative
exclude
paths defined inpyproject.toml
files are now evaluated relative to the location of the file, not the current working directory.
Relative paths provided to the--exclude
option (or env var) are evaluated relative to the current working directory. Files and exclude paths
are now compared as resolved, absolute paths. (Fixes #431 - thank you @cmcnicoll!) - Fixes a bug where a comment like
{#-- comment --#}
would cause a false positive for the
comment safety check. (#434)
Formatting Changes
- sqlfmt now supports the
<=>
operator (#432 - thank you @kathykwon!)
[0.18.3] - 2023-05-31
Bug Fixes
- fixes a bug where multiple c-style comments (e.g.,
/* comment */
) on a single line would cause sqlfmt
to not include all comments in formatted output (#419 - thank you @aersam!)
Features
- adds a safety check to ensure comments are preserved in formatted output
[0.18.2] - 2023-05-31
- fixes a bug where specifying both relative and absolute paths would cause sqlfmt to crash (#426 - thank you for the issue and fix, @smcgivern!)
[0.18.1] - 2023-05-10
- fixes a bug when lexing
union distinct
tokens (#417 - thank you, @paschmaria!)
[0.18.0] - 2023-04-19
Formatting Changes
-
the contents of jinja blocks are now indented if the block wraps onto multiple rows (#403). This is now the proper sqlfmt style:
select some_field, {% for some_item in some_sequence %} some_function({{ some_item }}){% if not loop.last %}, {% endif %} {% endfor %}
While in this simple example the new style makes it less clear
thatsome_field
andsome_function
are at the
same SQL depth, the formatting of complex files with nested jinja blocks is much improved.
For example:{%- for col in cols -%} {%- if col.column.lower() not in remove | map( "lower" ) and col.column.lower() not in exclude | map("lower") -%} {% do include_cols.append(col) %} {%- endif %} {%- endfor %}
See also this discussion. Thank you
@dave-connors-3 and
@alrocar! -
sqlfmt now supports all Postgres frame clauses, not just those that start with
rows between
. (#404)
[0.17.1] - 2023-04-12
Bug Fixes
- fixed a bug where format-off tokens could cause sqlfmt to raise a bracket mismatch error (#395 - thank you, @AndrewLaneAtPowerSchool!).
[0.17.0] - 2023-02-24
Features
- sqlfmt now defaults to reading and writing files using the
utf-8
encoding. Previously, we used Python's default behavior of using the encoding from the host machine's locale. However, asutf-8
becomes a de-facto standard, this was causing issues for some Windows users, whose locale was set to use older encodings. You can use the--encoding
option to specify a different encoding. Setting encoding toinherit
, e.g.,sqlfmt --encoding inherit foo.sql
will revert to the old behavior of using the host's locale. sqlfmt will detect and preserve a UTF BOM if it is present. If you specify--encoding utf-8-sig
, sqlfmt will always write a UTF-8 BOM in the formatted file. (#350, #381, #383 - thank you @profesia-company, @cmcnicoll, @aersam, and @ryanmeekins!)
[0.16.0] - 2023-01-27
Formatting Changes + Bug Fixes
- sqlfmt no longer merges lines that contain comments, unless the position of those comments can be preserved (#348 - thank you, @rileyschack and @IanEdington!). Accordingly, comments that are inline will stay inline, even if they are too long to fit.
- sqlfmt no longer merges together lines containing multiline jinja blocks unless those lines start with an operator or comma (#365 - thank you, @gavlt!).
- fixed a bug where adding a jinja end tag (e.g.,
{% endif %}
) to a line could cause bad formatting of everything on that line
[0.15.2] - 2023-01-23
Features
- adds support for ARM-based platforms using Docker.
[0.15.1] - 2023-01-20
Features
- added a Dockerfile for running sqlfmt in a container. New versions of sqlfmt will include Docker builds pushed to the GitHub...
v0.23.0
sqlfmt CHANGELOG
All notable changes to this project will be documented in this file.
[Unreleased]
[0.23.0] - 2024-07-26
Formatting Changes and Bug Fixes
- sqlfmt will now parse unquoted reserved keywords as names if they are qualified by a period, e.g.,
foo.select
orfoo.case
(#599 - thank you @matthieucan!).
[0.22.0] - 2024-07-25
Formatting Changes and Bug Fixes
- DuckDB's
union [all] by name
is now supported (#611 - thank you @aersam!). interval
is now parsed as a word operator. Parenthesized expressions likeinterval (10) days
will maintain the space afterinterval
.- Fixed a bug where a line starting with an operator or word operator could be erroneously merged into a previous line (#602 - thank you @roveo!).
[0.21.4] - 2024-07-09
Formatting Changes and Bug Fixes
- Databricks
left anti
&right anti
joins are now supported.
[0.21.3] - 2024-04-25
Bug Fixes
- The Postgres operators for
(NOT) (I)LIKE
,~~
,~~*
,!~~
,!~~*
, are now supported (these use two tildes where the posix version of these operators use a single tilde) (#576 - thank you @tuckerrc!).
[0.21.2] - 2024-01-22
Bug Fixes
{% for %}...{% else %}...{% endfor %}
loops are now supported. Previously, a BracketError was raised if afor
loop included anelse
tag (#549 - thank you, @yassun7010!).
[0.21.1] - 2023-12-19
Bug Fixes
- Fixes a bug where extra indentation was added inside multiline jinja tags if those jinja tags contained a python multiline string (#536 - thank you @yassun7010!).
[0.21.0] - 2023-10-20
Bug Fixes
- Adds support for the
map<...>
type declaration syntax from Athena. (#500 - thank you for the issue and fix, @benjamin-awd!) - Fixes a bug where nested dicts inside jinja expressions (e.g.,
{{ {'a': {'b': 1}} }}
) could cause parsing errors (#471 - thank you @rparvathaneni-sc and @benjamin-awd!). This fix introduces a dependency on jinja2 > v3.0. - Fixes a bug in the lexing logic that prevented the walrus operator (
:=
) from being lexed as a single token (#502 - thank you @federico-hero!).
[0.20.0] - 2023-09-25
BREAKING CHANGES
- Drops support for Python 3.7. Please upgrade to Python 3.8 or higher.
Formatting Changes and Bug Fixes
any()
andall()
will no longer get spaces between the function name and the parenthesis, unless they are a part of alike any ()
orlike all ()
operator (#483 - thank you @damirbk!).- Snowflake's
//
comment markers are now parsed as comments and rewritten to--
on formatting (#468 - thank you @nilsonavp!). - DuckDB's
semi
,anti
,positional
, andasof
joins are now supported. (#482).
[0.19.2] - 2023-07-31
Bug Fixes
- Fixes a bug where
--exclude
would not follow symlinks when globbing
(#457 - thank you @jeancochrane!).
[0.19.1] - 2023-07-13
Bug Fixes
- Fixes a bug where
--fmt: off
comments could cause an error in formatting a file
(#447 - thank you @ramonvermeulen!). - Fixes a bug where some formatting changes were applied to sections of code in
--fmt: off
blocks. - Fixes a bug where comments inside of
--fmt: off
would still be formatted.
(#136).
[0.19.0] - 2023-06-08
Bug Fixes
- Relative
exclude
paths defined inpyproject.toml
files are now evaluated relative to the location of the file, not the current working directory.
Relative paths provided to the--exclude
option (or env var) are evaluated relative to the current working directory. Files and exclude paths
are now compared as resolved, absolute paths. (Fixes #431 - thank you @cmcnicoll!) - Fixes a bug where a comment like
{#-- comment --#}
would cause a false positive for the
comment safety check. (#434)
Formatting Changes
- sqlfmt now supports the
<=>
operator (#432 - thank you @kathykwon!)
[0.18.3] - 2023-05-31
Bug Fixes
- fixes a bug where multiple c-style comments (e.g.,
/* comment */
) on a single line would cause sqlfmt
to not include all comments in formatted output (#419 - thank you @aersam!)
Features
- adds a safety check to ensure comments are preserved in formatted output
[0.18.2] - 2023-05-31
- fixes a bug where specifying both relative and absolute paths would cause sqlfmt to crash (#426 - thank you for the issue and fix, @smcgivern!)
[0.18.1] - 2023-05-10
- fixes a bug when lexing
union distinct
tokens (#417 - thank you, @paschmaria!)
[0.18.0] - 2023-04-19
Formatting Changes
-
the contents of jinja blocks are now indented if the block wraps onto multiple rows (#403). This is now the proper sqlfmt style:
select some_field, {% for some_item in some_sequence %} some_function({{ some_item }}){% if not loop.last %}, {% endif %} {% endfor %}
While in this simple example the new style makes it less clear
thatsome_field
andsome_function
are at the
same SQL depth, the formatting of complex files with nested jinja blocks is much improved.
For example:{%- for col in cols -%} {%- if col.column.lower() not in remove | map( "lower" ) and col.column.lower() not in exclude | map("lower") -%} {% do include_cols.append(col) %} {%- endif %} {%- endfor %}
See also this discussion. Thank you
@dave-connors-3 and
@alrocar! -
sqlfmt now supports all Postgres frame clauses, not just those that start with
rows between
. (#404)
[0.17.1] - 2023-04-12
Bug Fixes
- fixed a bug where format-off tokens could cause sqlfmt to raise a bracket mismatch error (#395 - thank you, @AndrewLaneAtPowerSchool!).
[0.17.0] - 2023-02-24
Features
- sqlfmt now defaults to reading and writing files using the
utf-8
encoding. Previously, we used Python's default behavior of using the encoding from the host machine's locale. However, asutf-8
becomes a de-facto standard, this was causing issues for some Windows users, whose locale was set to use older encodings. You can use the--encoding
option to specify a different encoding. Setting encoding toinherit
, e.g.,sqlfmt --encoding inherit foo.sql
will revert to the old behavior of using the host's locale. sqlfmt will detect and preserve a UTF BOM if it is present. If you specify--encoding utf-8-sig
, sqlfmt will always write a UTF-8 BOM in the formatted file. (#350, #381, #383 - thank you @profesia-company, @cmcnicoll, @aersam, and @ryanmeekins!)
[0.16.0] - 2023-01-27
Formatting Changes + Bug Fixes
- sqlfmt no longer merges lines that contain comments, unless the position of those comments can be preserved (#348 - thank you, @rileyschack and @IanEdington!). Accordingly, comments that are inline will stay inline, even if they are too long to fit.
- sqlfmt no longer merges together lines containing multiline jinja blocks unless those lines start with an operator or comma (#365 - thank you, @gavlt!).
- fixed a bug where adding a jinja end tag (e.g.,
{% endif %}
) to a line could cause bad formatting of everything on that line
[0.15.2] - 2023-01-23
Features
- adds support for ARM-based platforms using Docker.
[0.15.1] - 2023-01-20
Features
- added a Dockerfile for running sqlfmt in a container. New versions of sqlfmt will include Docker builds pushed to the GitHub Container Registry (thank you @ysmilda!).
[0.15.0] - 2023-01-18
Formatting Changes + Bug Fixes
- sqlfmt now re...
v0.22.0
sqlfmt CHANGELOG
All notable changes to this project will be documented in this file.
[Unreleased]
[0.22.0] - 2024-07-25
Formatting Changes and Bug Fixes
- DuckDB's
union [all] by name
is now supported (#611 - thank you @aersam!). interval
is now parsed as a word operator. Parenthesized expressions likeinterval (10) days
will maintain the space afterinterval
.- Fixed a bug where a line starting with an operator or word operator could be erroneously merged into a previous line (#602 - thank you @roveo!).
[0.21.4] - 2024-07-09
Formatting Changes and Bug Fixes
- Databricks
left anti
&right anti
joins are now supported.
[0.21.3] - 2024-04-25
Bug Fixes
- The Postgres operators for
(NOT) (I)LIKE
,~~
,~~*
,!~~
,!~~*
, are now supported (these use two tildes where the posix version of these operators use a single tilde) (#576 - thank you @tuckerrc!).
[0.21.2] - 2024-01-22
Bug Fixes
{% for %}...{% else %}...{% endfor %}
loops are now supported. Previously, a BracketError was raised if afor
loop included anelse
tag (#549 - thank you, @yassun7010!).
[0.21.1] - 2023-12-19
Bug Fixes
- Fixes a bug where extra indentation was added inside multiline jinja tags if those jinja tags contained a python multiline string (#536 - thank you @yassun7010!).
[0.21.0] - 2023-10-20
Bug Fixes
- Adds support for the
map<...>
type declaration syntax from Athena. (#500 - thank you for the issue and fix, @benjamin-awd!) - Fixes a bug where nested dicts inside jinja expressions (e.g.,
{{ {'a': {'b': 1}} }}
) could cause parsing errors (#471 - thank you @rparvathaneni-sc and @benjamin-awd!). This fix introduces a dependency on jinja2 > v3.0. - Fixes a bug in the lexing logic that prevented the walrus operator (
:=
) from being lexed as a single token (#502 - thank you @federico-hero!).
[0.20.0] - 2023-09-25
BREAKING CHANGES
- Drops support for Python 3.7. Please upgrade to Python 3.8 or higher.
Formatting Changes and Bug Fixes
any()
andall()
will no longer get spaces between the function name and the parenthesis, unless they are a part of alike any ()
orlike all ()
operator (#483 - thank you @damirbk!).- Snowflake's
//
comment markers are now parsed as comments and rewritten to--
on formatting (#468 - thank you @nilsonavp!). - DuckDB's
semi
,anti
,positional
, andasof
joins are now supported. (#482).
[0.19.2] - 2023-07-31
Bug Fixes
- Fixes a bug where
--exclude
would not follow symlinks when globbing
(#457 - thank you @jeancochrane!).
[0.19.1] - 2023-07-13
Bug Fixes
- Fixes a bug where
--fmt: off
comments could cause an error in formatting a file
(#447 - thank you @ramonvermeulen!). - Fixes a bug where some formatting changes were applied to sections of code in
--fmt: off
blocks. - Fixes a bug where comments inside of
--fmt: off
would still be formatted.
(#136).
[0.19.0] - 2023-06-08
Bug Fixes
- Relative
exclude
paths defined inpyproject.toml
files are now evaluated relative to the location of the file, not the current working directory.
Relative paths provided to the--exclude
option (or env var) are evaluated relative to the current working directory. Files and exclude paths
are now compared as resolved, absolute paths. (Fixes #431 - thank you @cmcnicoll!) - Fixes a bug where a comment like
{#-- comment --#}
would cause a false positive for the
comment safety check. (#434)
Formatting Changes
- sqlfmt now supports the
<=>
operator (#432 - thank you @kathykwon!)
[0.18.3] - 2023-05-31
Bug Fixes
- fixes a bug where multiple c-style comments (e.g.,
/* comment */
) on a single line would cause sqlfmt
to not include all comments in formatted output (#419 - thank you @aersam!)
Features
- adds a safety check to ensure comments are preserved in formatted output
[0.18.2] - 2023-05-31
- fixes a bug where specifying both relative and absolute paths would cause sqlfmt to crash (#426 - thank you for the issue and fix, @smcgivern!)
[0.18.1] - 2023-05-10
- fixes a bug when lexing
union distinct
tokens (#417 - thank you, @paschmaria!)
[0.18.0] - 2023-04-19
Formatting Changes
-
the contents of jinja blocks are now indented if the block wraps onto multiple rows (#403). This is now the proper sqlfmt style:
select some_field, {% for some_item in some_sequence %} some_function({{ some_item }}){% if not loop.last %}, {% endif %} {% endfor %}
While in this simple example the new style makes it less clear
thatsome_field
andsome_function
are at the
same SQL depth, the formatting of complex files with nested jinja blocks is much improved.
For example:{%- for col in cols -%} {%- if col.column.lower() not in remove | map( "lower" ) and col.column.lower() not in exclude | map("lower") -%} {% do include_cols.append(col) %} {%- endif %} {%- endfor %}
See also this discussion. Thank you
@dave-connors-3 and
@alrocar! -
sqlfmt now supports all Postgres frame clauses, not just those that start with
rows between
. (#404)
[0.17.1] - 2023-04-12
Bug Fixes
- fixed a bug where format-off tokens could cause sqlfmt to raise a bracket mismatch error (#395 - thank you, @AndrewLaneAtPowerSchool!).
[0.17.0] - 2023-02-24
Features
- sqlfmt now defaults to reading and writing files using the
utf-8
encoding. Previously, we used Python's default behavior of using the encoding from the host machine's locale. However, asutf-8
becomes a de-facto standard, this was causing issues for some Windows users, whose locale was set to use older encodings. You can use the--encoding
option to specify a different encoding. Setting encoding toinherit
, e.g.,sqlfmt --encoding inherit foo.sql
will revert to the old behavior of using the host's locale. sqlfmt will detect and preserve a UTF BOM if it is present. If you specify--encoding utf-8-sig
, sqlfmt will always write a UTF-8 BOM in the formatted file. (#350, #381, #383 - thank you @profesia-company, @cmcnicoll, @aersam, and @ryanmeekins!)
[0.16.0] - 2023-01-27
Formatting Changes + Bug Fixes
- sqlfmt no longer merges lines that contain comments, unless the position of those comments can be preserved (#348 - thank you, @rileyschack and @IanEdington!). Accordingly, comments that are inline will stay inline, even if they are too long to fit.
- sqlfmt no longer merges together lines containing multiline jinja blocks unless those lines start with an operator or comma (#365 - thank you, @gavlt!).
- fixed a bug where adding a jinja end tag (e.g.,
{% endif %}
) to a line could cause bad formatting of everything on that line
[0.15.2] - 2023-01-23
Features
- adds support for ARM-based platforms using Docker.
[0.15.1] - 2023-01-20
Features
- added a Dockerfile for running sqlfmt in a container. New versions of sqlfmt will include Docker builds pushed to the GitHub Container Registry (thank you @ysmilda!).
[0.15.0] - 2023-01-18
Formatting Changes + Bug Fixes
v0.21.4
sqlfmt CHANGELOG
All notable changes to this project will be documented in this file.
[Unreleased]
[0.21.4] - 2024-07-09
Formatting Changes and Bug Fixes
- Databricks
left anti
&right anti
joins are now supported.
[0.21.3] - 2024-04-25
Bug Fixes
- The Postgres operators for
(NOT) (I)LIKE
,~~
,~~*
,!~~
,!~~*
, are now supported (these use two tildes where the posix version of these operators use a single tilde) (#576 - thank you @tuckerrc!).
[0.21.2] - 2024-01-22
Bug Fixes
{% for %}...{% else %}...{% endfor %}
loops are now supported. Previously, a BracketError was raised if afor
loop included anelse
tag (#549 - thank you, @yassun7010!).
[0.21.1] - 2023-12-19
Bug Fixes
- Fixes a bug where extra indentation was added inside multiline jinja tags if those jinja tags contained a python multiline string (#536 - thank you @yassun7010!).
[0.21.0] - 2023-10-20
Bug Fixes
- Adds support for the
map<...>
type declaration syntax from Athena. (#500 - thank you for the issue and fix, @benjamin-awd!) - Fixes a bug where nested dicts inside jinja expressions (e.g.,
{{ {'a': {'b': 1}} }}
) could cause parsing errors (#471 - thank you @rparvathaneni-sc and @benjamin-awd!). This fix introduces a dependency on jinja2 > v3.0. - Fixes a bug in the lexing logic that prevented the walrus operator (
:=
) from being lexed as a single token (#502 - thank you @federico-hero!).
[0.20.0] - 2023-09-25
BREAKING CHANGES
- Drops support for Python 3.7. Please upgrade to Python 3.8 or higher.
Formatting Changes and Bug Fixes
any()
andall()
will no longer get spaces between the function name and the parenthesis, unless they are a part of alike any ()
orlike all ()
operator (#483 - thank you @damirbk!).- Snowflake's
//
comment markers are now parsed as comments and rewritten to--
on formatting (#468 - thank you @nilsonavp!). - DuckDB's
semi
,anti
,positional
, andasof
joins are now supported. (#482).
[0.19.2] - 2023-07-31
Bug Fixes
- Fixes a bug where
--exclude
would not follow symlinks when globbing
(#457 - thank you @jeancochrane!).
[0.19.1] - 2023-07-13
Bug Fixes
- Fixes a bug where
--fmt: off
comments could cause an error in formatting a file
(#447 - thank you @ramonvermeulen!). - Fixes a bug where some formatting changes were applied to sections of code in
--fmt: off
blocks. - Fixes a bug where comments inside of
--fmt: off
would still be formatted.
(#136).
[0.19.0] - 2023-06-08
Bug Fixes
- Relative
exclude
paths defined inpyproject.toml
files are now evaluated relative to the location of the file, not the current working directory.
Relative paths provided to the--exclude
option (or env var) are evaluated relative to the current working directory. Files and exclude paths
are now compared as resolved, absolute paths. (Fixes #431 - thank you @cmcnicoll!) - Fixes a bug where a comment like
{#-- comment --#}
would cause a false positive for the
comment safety check. (#434)
Formatting Changes
- sqlfmt now supports the
<=>
operator (#432 - thank you @kathykwon!)
[0.18.3] - 2023-05-31
Bug Fixes
- fixes a bug where multiple c-style comments (e.g.,
/* comment */
) on a single line would cause sqlfmt
to not include all comments in formatted output (#419 - thank you @aersam!)
Features
- adds a safety check to ensure comments are preserved in formatted output
[0.18.2] - 2023-05-31
- fixes a bug where specifying both relative and absolute paths would cause sqlfmt to crash (#426 - thank you for the issue and fix, @smcgivern!)
[0.18.1] - 2023-05-10
- fixes a bug when lexing
union distinct
tokens (#417 - thank you, @paschmaria!)
[0.18.0] - 2023-04-19
Formatting Changes
-
the contents of jinja blocks are now indented if the block wraps onto multiple rows (#403). This is now the proper sqlfmt style:
select some_field, {% for some_item in some_sequence %} some_function({{ some_item }}){% if not loop.last %}, {% endif %} {% endfor %}
While in this simple example the new style makes it less clear
thatsome_field
andsome_function
are at the
same SQL depth, the formatting of complex files with nested jinja blocks is much improved.
For example:{%- for col in cols -%} {%- if col.column.lower() not in remove | map( "lower" ) and col.column.lower() not in exclude | map("lower") -%} {% do include_cols.append(col) %} {%- endif %} {%- endfor %}
See also this discussion. Thank you
@dave-connors-3 and
@alrocar! -
sqlfmt now supports all Postgres frame clauses, not just those that start with
rows between
. (#404)
[0.17.1] - 2023-04-12
Bug Fixes
- fixed a bug where format-off tokens could cause sqlfmt to raise a bracket mismatch error (#395 - thank you, @AndrewLaneAtPowerSchool!).
[0.17.0] - 2023-02-24
Features
- sqlfmt now defaults to reading and writing files using the
utf-8
encoding. Previously, we used Python's default behavior of using the encoding from the host machine's locale. However, asutf-8
becomes a de-facto standard, this was causing issues for some Windows users, whose locale was set to use older encodings. You can use the--encoding
option to specify a different encoding. Setting encoding toinherit
, e.g.,sqlfmt --encoding inherit foo.sql
will revert to the old behavior of using the host's locale. sqlfmt will detect and preserve a UTF BOM if it is present. If you specify--encoding utf-8-sig
, sqlfmt will always write a UTF-8 BOM in the formatted file. (#350, #381, #383 - thank you @profesia-company, @cmcnicoll, @aersam, and @ryanmeekins!)
[0.16.0] - 2023-01-27
Formatting Changes + Bug Fixes
- sqlfmt no longer merges lines that contain comments, unless the position of those comments can be preserved (#348 - thank you, @rileyschack and @IanEdington!). Accordingly, comments that are inline will stay inline, even if they are too long to fit.
- sqlfmt no longer merges together lines containing multiline jinja blocks unless those lines start with an operator or comma (#365 - thank you, @gavlt!).
- fixed a bug where adding a jinja end tag (e.g.,
{% endif %}
) to a line could cause bad formatting of everything on that line
[0.15.2] - 2023-01-23
Features
- adds support for ARM-based platforms using Docker.
[0.15.1] - 2023-01-20
Features
- added a Dockerfile for running sqlfmt in a container. New versions of sqlfmt will include Docker builds pushed to the GitHub Container Registry (thank you @ysmilda!).
[0.15.0] - 2023-01-18
Formatting Changes + Bug Fixes
- sqlfmt now removes extra blank lines (#249 - thank you, @nfcampos!). Basically, no more than 1 blank line inside queries or blocks; no more than 2 between queries or blocks.
- sqlfmt now supports
create <object> ... clone
statements (#313). - sqlfmt will now format all files that end with
*.sql
and*.sql.jinja
, even those with other dots in their filenames (#354 - thank you @ysmilda!). - fixed a bug where
{% call %}
blocks with arguments like{% call(foo) bar(baz) %}
would cause a parsing error (#353 - thank you @IgnorantWalking!). - sqlfmt now supports [bun placeholders](https://bun.uptrace.dev/gui...
v0.21.3
sqlfmt CHANGELOG
All notable changes to this project will be documented in this file.
[Unreleased]
[0.21.3] - 2024-04-25
Bug Fixes
- The Postgres operators for
(NOT) (I)LIKE
,~~
,~~*
,!~~
,!~~*
, are now supported (these use two tildes where the posix version of these operators use a single tilde) (#576 - thank you @tuckerrc!).
[0.21.2] - 2024-01-22
Bug Fixes
{% for %}...{% else %}...{% endfor %}
loops are now supported. Previously, a BracketError was raised if afor
loop included anelse
tag (#549 - thank you, @yassun7010!).
[0.21.1] - 2023-12-19
Bug Fixes
- Fixes a bug where extra indentation was added inside multiline jinja tags if those jinja tags contained a python multiline string (#536 - thank you @yassun7010!).
[0.21.0] - 2023-10-20
Bug Fixes
- Adds support for the
map<...>
type declaration syntax from Athena. (#500 - thank you for the issue and fix, @benjamin-awd!) - Fixes a bug where nested dicts inside jinja expressions (e.g.,
{{ {'a': {'b': 1}} }}
) could cause parsing errors (#471 - thank you @rparvathaneni-sc and @benjamin-awd!). This fix introduces a dependency on jinja2 > v3.0. - Fixes a bug in the lexing logic that prevented the walrus operator (
:=
) from being lexed as a single token (#502 - thank you @federico-hero!).
[0.20.0] - 2023-09-25
BREAKING CHANGES
- Drops support for Python 3.7. Please upgrade to Python 3.8 or higher.
Formatting Changes and Bug Fixes
any()
andall()
will no longer get spaces between the function name and the parenthesis, unless they are a part of alike any ()
orlike all ()
operator (#483 - thank you @damirbk!).- Snowflake's
//
comment markers are now parsed as comments and rewritten to--
on formatting (#468 - thank you @nilsonavp!). - DuckDB's
semi
,anti
,positional
, andasof
joins are now supported. (#482).
[0.19.2] - 2023-07-31
Bug Fixes
- Fixes a bug where
--exclude
would not follow symlinks when globbing
(#457 - thank you @jeancochrane!).
[0.19.1] - 2023-07-13
Bug Fixes
- Fixes a bug where
--fmt: off
comments could cause an error in formatting a file
(#447 - thank you @ramonvermeulen!). - Fixes a bug where some formatting changes were applied to sections of code in
--fmt: off
blocks. - Fixes a bug where comments inside of
--fmt: off
would still be formatted.
(#136).
[0.19.0] - 2023-06-08
Bug Fixes
- Relative
exclude
paths defined inpyproject.toml
files are now evaluated relative to the location of the file, not the current working directory.
Relative paths provided to the--exclude
option (or env var) are evaluated relative to the current working directory. Files and exclude paths
are now compared as resolved, absolute paths. (Fixes #431 - thank you @cmcnicoll!) - Fixes a bug where a comment like
{#-- comment --#}
would cause a false positive for the
comment safety check. (#434)
Formatting Changes
- sqlfmt now supports the
<=>
operator (#432 - thank you @kathykwon!)
[0.18.3] - 2023-05-31
Bug Fixes
- fixes a bug where multiple c-style comments (e.g.,
/* comment */
) on a single line would cause sqlfmt
to not include all comments in formatted output (#419 - thank you @aersam!)
Features
- adds a safety check to ensure comments are preserved in formatted output
[0.18.2] - 2023-05-31
- fixes a bug where specifying both relative and absolute paths would cause sqlfmt to crash (#426 - thank you for the issue and fix, @smcgivern!)
[0.18.1] - 2023-05-10
- fixes a bug when lexing
union distinct
tokens (#417 - thank you, @paschmaria!)
[0.18.0] - 2023-04-19
Formatting Changes
-
the contents of jinja blocks are now indented if the block wraps onto multiple rows (#403). This is now the proper sqlfmt style:
select some_field, {% for some_item in some_sequence %} some_function({{ some_item }}){% if not loop.last %}, {% endif %} {% endfor %}
While in this simple example the new style makes it less clear
thatsome_field
andsome_function
are at the
same SQL depth, the formatting of complex files with nested jinja blocks is much improved.
For example:{%- for col in cols -%} {%- if col.column.lower() not in remove | map( "lower" ) and col.column.lower() not in exclude | map("lower") -%} {% do include_cols.append(col) %} {%- endif %} {%- endfor %}
See also this discussion. Thank you
@dave-connors-3 and
@alrocar! -
sqlfmt now supports all Postgres frame clauses, not just those that start with
rows between
. (#404)
[0.17.1] - 2023-04-12
Bug Fixes
- fixed a bug where format-off tokens could cause sqlfmt to raise a bracket mismatch error (#395 - thank you, @AndrewLaneAtPowerSchool!).
[0.17.0] - 2023-02-24
Features
- sqlfmt now defaults to reading and writing files using the
utf-8
encoding. Previously, we used Python's default behavior of using the encoding from the host machine's locale. However, asutf-8
becomes a de-facto standard, this was causing issues for some Windows users, whose locale was set to use older encodings. You can use the--encoding
option to specify a different encoding. Setting encoding toinherit
, e.g.,sqlfmt --encoding inherit foo.sql
will revert to the old behavior of using the host's locale. sqlfmt will detect and preserve a UTF BOM if it is present. If you specify--encoding utf-8-sig
, sqlfmt will always write a UTF-8 BOM in the formatted file. (#350, #381, #383 - thank you @profesia-company, @cmcnicoll, @aersam, and @ryanmeekins!)
[0.16.0] - 2023-01-27
Formatting Changes + Bug Fixes
- sqlfmt no longer merges lines that contain comments, unless the position of those comments can be preserved (#348 - thank you, @rileyschack and @IanEdington!). Accordingly, comments that are inline will stay inline, even if they are too long to fit.
- sqlfmt no longer merges together lines containing multiline jinja blocks unless those lines start with an operator or comma (#365 - thank you, @gavlt!).
- fixed a bug where adding a jinja end tag (e.g.,
{% endif %}
) to a line could cause bad formatting of everything on that line
[0.15.2] - 2023-01-23
Features
- adds support for ARM-based platforms using Docker.
[0.15.1] - 2023-01-20
Features
- added a Dockerfile for running sqlfmt in a container. New versions of sqlfmt will include Docker builds pushed to the GitHub Container Registry (thank you @ysmilda!).
[0.15.0] - 2023-01-18
Formatting Changes + Bug Fixes
- sqlfmt now removes extra blank lines (#249 - thank you, @nfcampos!). Basically, no more than 1 blank line inside queries or blocks; no more than 2 between queries or blocks.
- sqlfmt now supports
create <object> ... clone
statements (#313). - sqlfmt will now format all files that end with
*.sql
and*.sql.jinja
, even those with other dots in their filenames (#354 - thank you @ysmilda!). - fixed a bug where
{% call %}
blocks with arguments like{% call(foo) bar(baz) %}
would cause a parsing error (#353 - thank you @IgnorantWalking!). - sqlfmt now supports [bun placeholders](https://bun.uptrace.dev/g...
v0.21.2
sqlfmt CHANGELOG
All notable changes to this project will be documented in this file.
[Unreleased]
[0.21.2] - 2024-01-22
Bug Fixes
{% for %}...{% else %}...{% endfor %}
loops are now supported. Previously, a BracketError was raised if afor
loop included anelse
tag (#549 - thank you, @yassun7010!).
[0.21.1] - 2023-12-19
Bug Fixes
- Fixes a bug where extra indentation was added inside multiline jinja tags if those jinja tags contained a python multiline string (#536 - thank you @yassun7010!).
[0.21.0] - 2023-10-20
Bug Fixes
- Adds support for the
map<...>
type declaration syntax from Athena. (#500 - thank you for the issue and fix, @benjamin-awd!) - Fixes a bug where nested dicts inside jinja expressions (e.g.,
{{ {'a': {'b': 1}} }}
) could cause parsing errors (#471 - thank you @rparvathaneni-sc and @benjamin-awd!). This fix introduces a dependency on jinja2 > v3.0. - Fixes a bug in the lexing logic that prevented the walrus operator (
:=
) from being lexed as a single token (#502 - thank you @federico-hero!).
[0.20.0] - 2023-09-25
BREAKING CHANGES
- Drops support for Python 3.7. Please upgrade to Python 3.8 or higher.
Formatting Changes and Bug Fixes
any()
andall()
will no longer get spaces between the function name and the parenthesis, unless they are a part of alike any ()
orlike all ()
operator (#483 - thank you @damirbk!).- Snowflake's
//
comment markers are now parsed as comments and rewritten to--
on formatting (#468 - thank you @nilsonavp!). - DuckDB's
semi
,anti
,positional
, andasof
joins are now supported. (#482).
[0.19.2] - 2023-07-31
Bug Fixes
- Fixes a bug where
--exclude
would not follow symlinks when globbing
(#457 - thank you @jeancochrane!).
[0.19.1] - 2023-07-13
Bug Fixes
- Fixes a bug where
--fmt: off
comments could cause an error in formatting a file
(#447 - thank you @ramonvermeulen!). - Fixes a bug where some formatting changes were applied to sections of code in
--fmt: off
blocks. - Fixes a bug where comments inside of
--fmt: off
would still be formatted.
(#136).
[0.19.0] - 2023-06-08
Bug Fixes
- Relative
exclude
paths defined inpyproject.toml
files are now evaluated relative to the location of the file, not the current working directory.
Relative paths provided to the--exclude
option (or env var) are evaluated relative to the current working directory. Files and exclude paths
are now compared as resolved, absolute paths. (Fixes #431 - thank you @cmcnicoll!) - Fixes a bug where a comment like
{#-- comment --#}
would cause a false positive for the
comment safety check. (#434)
Formatting Changes
- sqlfmt now supports the
<=>
operator (#432 - thank you @kathykwon!)
[0.18.3] - 2023-05-31
Bug Fixes
- fixes a bug where multiple c-style comments (e.g.,
/* comment */
) on a single line would cause sqlfmt
to not include all comments in formatted output (#419 - thank you @aersam!)
Features
- adds a safety check to ensure comments are preserved in formatted output
[0.18.2] - 2023-05-31
- fixes a bug where specifying both relative and absolute paths would cause sqlfmt to crash (#426 - thank you for the issue and fix, @smcgivern!)
[0.18.1] - 2023-05-10
- fixes a bug when lexing
union distinct
tokens (#417 - thank you, @paschmaria!)
[0.18.0] - 2023-04-19
Formatting Changes
-
the contents of jinja blocks are now indented if the block wraps onto multiple rows (#403). This is now the proper sqlfmt style:
select some_field, {% for some_item in some_sequence %} some_function({{ some_item }}){% if not loop.last %}, {% endif %} {% endfor %}
While in this simple example the new style makes it less clear
thatsome_field
andsome_function
are at the
same SQL depth, the formatting of complex files with nested jinja blocks is much improved.
For example:{%- for col in cols -%} {%- if col.column.lower() not in remove | map( "lower" ) and col.column.lower() not in exclude | map("lower") -%} {% do include_cols.append(col) %} {%- endif %} {%- endfor %}
See also this discussion. Thank you
@dave-connors-3 and
@alrocar! -
sqlfmt now supports all Postgres frame clauses, not just those that start with
rows between
. (#404)
[0.17.1] - 2023-04-12
Bug Fixes
- fixed a bug where format-off tokens could cause sqlfmt to raise a bracket mismatch error (#395 - thank you, @AndrewLaneAtPowerSchool!).
[0.17.0] - 2023-02-24
Features
- sqlfmt now defaults to reading and writing files using the
utf-8
encoding. Previously, we used Python's default behavior of using the encoding from the host machine's locale. However, asutf-8
becomes a de-facto standard, this was causing issues for some Windows users, whose locale was set to use older encodings. You can use the--encoding
option to specify a different encoding. Setting encoding toinherit
, e.g.,sqlfmt --encoding inherit foo.sql
will revert to the old behavior of using the host's locale. sqlfmt will detect and preserve a UTF BOM if it is present. If you specify--encoding utf-8-sig
, sqlfmt will always write a UTF-8 BOM in the formatted file. (#350, #381, #383 - thank you @profesia-company, @cmcnicoll, @aersam, and @ryanmeekins!)
[0.16.0] - 2023-01-27
Formatting Changes + Bug Fixes
- sqlfmt no longer merges lines that contain comments, unless the position of those comments can be preserved (#348 - thank you, @rileyschack and @IanEdington!). Accordingly, comments that are inline will stay inline, even if they are too long to fit.
- sqlfmt no longer merges together lines containing multiline jinja blocks unless those lines start with an operator or comma (#365 - thank you, @gavlt!).
- fixed a bug where adding a jinja end tag (e.g.,
{% endif %}
) to a line could cause bad formatting of everything on that line
[0.15.2] - 2023-01-23
Features
- adds support for ARM-based platforms using Docker.
[0.15.1] - 2023-01-20
Features
- added a Dockerfile for running sqlfmt in a container. New versions of sqlfmt will include Docker builds pushed to the GitHub Container Registry (thank you @ysmilda!).
[0.15.0] - 2023-01-18
Formatting Changes + Bug Fixes
- sqlfmt now removes extra blank lines (#249 - thank you, @nfcampos!). Basically, no more than 1 blank line inside queries or blocks; no more than 2 between queries or blocks.
- sqlfmt now supports
create <object> ... clone
statements (#313). - sqlfmt will now format all files that end with
*.sql
and*.sql.jinja
, even those with other dots in their filenames (#354 - thank you @ysmilda!). - fixed a bug where
{% call %}
blocks with arguments like{% call(foo) bar(baz) %}
would cause a parsing error (#353 - thank you @IgnorantWalking!). - sqlfmt now supports bun placeholders (#356 - thank you @ysmilda!)
Features
- by default, sqlfmt now runs an additional safety check that parses the formatted output to ensure it contains all of the same content as the raw input. This incurs a slight (~20%) p...
v0.21.1
sqlfmt CHANGELOG
All notable changes to this project will be documented in this file.
[Unreleased]
[0.21.1] - 2023-12-19
Bug Fixes
- Fixes a bug where extra indentation was added inside multiline jinja tags if those jinja tags contained a python multiline string (#536 - thank you @yassun7010!).
[0.21.0] - 2023-10-20
Bug Fixes
- Adds support for the
map<...>
type declaration syntax from Athena. (#500 - thank you for the issue and fix, @benjamin-awd!) - Fixes a bug where nested dicts inside jinja expressions (e.g.,
{{ {'a': {'b': 1}} }}
) could cause parsing errors (#471 - thank you @rparvathaneni-sc and @benjamin-awd!). This fix introduces a dependency on jinja2 > v3.0. - Fixes a bug in the lexing logic that prevented the walrus operator (
:=
) from being lexed as a single token (#502 - thank you @federico-hero!).
[0.20.0] - 2023-09-25
BREAKING CHANGES
- Drops support for Python 3.7. Please upgrade to Python 3.8 or higher.
Formatting Changes and Bug Fixes
any()
andall()
will no longer get spaces between the function name and the parenthesis, unless they are a part of alike any ()
orlike all ()
operator (#483 - thank you @damirbk!).- Snowflake's
//
comment markers are now parsed as comments and rewritten to--
on formatting (#468 - thank you @nilsonavp!). - DuckDB's
semi
,anti
,positional
, andasof
joins are now supported. (#482).
[0.19.2] - 2023-07-31
Bug Fixes
- Fixes a bug where
--exclude
would not follow symlinks when globbing
(#457 - thank you @jeancochrane!).
[0.19.1] - 2023-07-13
Bug Fixes
- Fixes a bug where
--fmt: off
comments could cause an error in formatting a file
(#447 - thank you @ramonvermeulen!). - Fixes a bug where some formatting changes were applied to sections of code in
--fmt: off
blocks. - Fixes a bug where comments inside of
--fmt: off
would still be formatted.
(#136).
[0.19.0] - 2023-06-08
Bug Fixes
- Relative
exclude
paths defined inpyproject.toml
files are now evaluated relative to the location of the file, not the current working directory.
Relative paths provided to the--exclude
option (or env var) are evaluated relative to the current working directory. Files and exclude paths
are now compared as resolved, absolute paths. (Fixes #431 - thank you @cmcnicoll!) - Fixes a bug where a comment like
{#-- comment --#}
would cause a false positive for the
comment safety check. (#434)
Formatting Changes
- sqlfmt now supports the
<=>
operator (#432 - thank you @kathykwon!)
[0.18.3] - 2023-05-31
Bug Fixes
- fixes a bug where multiple c-style comments (e.g.,
/* comment */
) on a single line would cause sqlfmt
to not include all comments in formatted output (#419 - thank you @aersam!)
Features
- adds a safety check to ensure comments are preserved in formatted output
[0.18.2] - 2023-05-31
- fixes a bug where specifying both relative and absolute paths would cause sqlfmt to crash (#426 - thank you for the issue and fix, @smcgivern!)
[0.18.1] - 2023-05-10
- fixes a bug when lexing
union distinct
tokens (#417 - thank you, @paschmaria!)
[0.18.0] - 2023-04-19
Formatting Changes
-
the contents of jinja blocks are now indented if the block wraps onto multiple rows (#403). This is now the proper sqlfmt style:
select some_field, {% for some_item in some_sequence %} some_function({{ some_item }}){% if not loop.last %}, {% endif %} {% endfor %}
While in this simple example the new style makes it less clear
thatsome_field
andsome_function
are at the
same SQL depth, the formatting of complex files with nested jinja blocks is much improved.
For example:{%- for col in cols -%} {%- if col.column.lower() not in remove | map( "lower" ) and col.column.lower() not in exclude | map("lower") -%} {% do include_cols.append(col) %} {%- endif %} {%- endfor %}
See also this discussion. Thank you
@dave-connors-3 and
@alrocar! -
sqlfmt now supports all Postgres frame clauses, not just those that start with
rows between
. (#404)
[0.17.1] - 2023-04-12
Bug Fixes
- fixed a bug where format-off tokens could cause sqlfmt to raise a bracket mismatch error (#395 - thank you, @AndrewLaneAtPowerSchool!).
[0.17.0] - 2023-02-24
Features
- sqlfmt now defaults to reading and writing files using the
utf-8
encoding. Previously, we used Python's default behavior of using the encoding from the host machine's locale. However, asutf-8
becomes a de-facto standard, this was causing issues for some Windows users, whose locale was set to use older encodings. You can use the--encoding
option to specify a different encoding. Setting encoding toinherit
, e.g.,sqlfmt --encoding inherit foo.sql
will revert to the old behavior of using the host's locale. sqlfmt will detect and preserve a UTF BOM if it is present. If you specify--encoding utf-8-sig
, sqlfmt will always write a UTF-8 BOM in the formatted file. (#350, #381, #383 - thank you @profesia-company, @cmcnicoll, @aersam, and @ryanmeekins!)
[0.16.0] - 2023-01-27
Formatting Changes + Bug Fixes
- sqlfmt no longer merges lines that contain comments, unless the position of those comments can be preserved (#348 - thank you, @rileyschack and @IanEdington!). Accordingly, comments that are inline will stay inline, even if they are too long to fit.
- sqlfmt no longer merges together lines containing multiline jinja blocks unless those lines start with an operator or comma (#365 - thank you, @gavlt!).
- fixed a bug where adding a jinja end tag (e.g.,
{% endif %}
) to a line could cause bad formatting of everything on that line
[0.15.2] - 2023-01-23
Features
- adds support for ARM-based platforms using Docker.
[0.15.1] - 2023-01-20
Features
- added a Dockerfile for running sqlfmt in a container. New versions of sqlfmt will include Docker builds pushed to the GitHub Container Registry (thank you @ysmilda!).
[0.15.0] - 2023-01-18
Formatting Changes + Bug Fixes
- sqlfmt now removes extra blank lines (#249 - thank you, @nfcampos!). Basically, no more than 1 blank line inside queries or blocks; no more than 2 between queries or blocks.
- sqlfmt now supports
create <object> ... clone
statements (#313). - sqlfmt will now format all files that end with
*.sql
and*.sql.jinja
, even those with other dots in their filenames (#354 - thank you @ysmilda!). - fixed a bug where
{% call %}
blocks with arguments like{% call(foo) bar(baz) %}
would cause a parsing error (#353 - thank you @IgnorantWalking!). - sqlfmt now supports bun placeholders (#356 - thank you @ysmilda!)
Features
- by default, sqlfmt now runs an additional safety check that parses the formatted output to ensure it contains all of the same content as the raw input. This incurs a slight (~20%) performance penalty. To bypass this safety check, you can use the command line option
--fast
, the corresponding TOML or environment variable config, or passMode(fast=True)
to any API method. The safety check is automatically bypassed if sqlfmt is run with the--check
or--diff
options. If the sa...