Skip to content

Releases: tconbeer/sqlfmt

v0.21.0

20 Oct 22:18
01a261b
Compare
Choose a tag to compare

sqlfmt CHANGELOG

All notable changes to this project will be documented in this file.

[Unreleased]

[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() and all() will no longer get spaces between the function name and the parenthesis, unless they are a part of a like any () or like 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, and asof 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 in pyproject.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

[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
    that some_field and some_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

[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, as utf-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 to inherit, 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 pass Mode(fast=True) to any API method. The safety check is automatically bypassed if sqlfmt is run with the --check or --diff options. If the safety check fails, the CLI will include an error in the report, and the format_string API will raise a SqlfmtEquivalenceError, which is a subclass of SqlfmtError.

[0.14.3] - 2023-01-05

Formatting Changes + Bug Fixes

  • fixed a bug where very long lines could raise `Recursion...
Read more

v0.20.0

25 Sep 20:25
Compare
Choose a tag to compare

sqlfmt CHANGELOG

All notable changes to this project will be documented in this file.

[Unreleased]

[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() and all() will no longer get spaces between the function name and the parenthesis, unless they are a part of a like any () or like 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, and asof 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 in pyproject.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

[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
    that some_field and some_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

[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, as utf-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 to inherit, 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 pass Mode(fast=True) to any API method. The safety check is automatically bypassed if sqlfmt is run with the --check or --diff options. If the safety check fails, the CLI will include an error in the report, and the format_string API will raise a SqlfmtEquivalenceError, which is a subclass of SqlfmtError.

[0.14.3] - 2023-01-05

Formatting Changes + Bug Fixes

  • fixed a bug where very long lines could raise RecursionError (#343 - thank you @kcem-flyr!).

[0.14.2] - 2022-12-12

Formatting Changes + Bug Fixes

  • fixed a bug where nested {% set %} and {% call %} blocks would cause a parsing error (#338 - thank you @AndrewLane!).

[0.14.1] - 2022-12-06

Formatting Changes + Bug Fixes

Read more

v0.19.2

31 Jul 14:55
9497dd6
Compare
Choose a tag to compare

sqlfmt CHANGELOG

All notable changes to this project will be documented in this file.

[Unreleased]

[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 in pyproject.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

[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
    that some_field and some_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

[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, as utf-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 to inherit, 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 pass Mode(fast=True) to any API method. The safety check is automatically bypassed if sqlfmt is run with the --check or --diff options. If the safety check fails, the CLI will include an error in the report, and the format_string API will raise a SqlfmtEquivalenceError, which is a subclass of SqlfmtError.

[0.14.3] - 2023-01-05

Formatting Changes + Bug Fixes

  • fixed a bug where very long lines could raise RecursionError (#343 - thank you @kcem-flyr!).

[0.14.2] - 2022-12-12

Formatting Changes + Bug Fixes

  • fixed a bug where nested {% set %} and {% call %} blocks would cause a parsing error (#338 - thank you @AndrewLane!).

[0.14.1] - 2022-12-06

Formatting Changes + Bug Fixes

  • sqlfmt now supports is [not] distinct from as a word operator (#327 - thank you @IgnorantWalking, @kadekillary!).
  • fixed a bug where jinja {% call %} blocks that called a macro that wasn't statement caused a parsing error (#335 - thank you @AndrewLane!).

Performance

  • sqlfmt runs finish in 20% less time due to algorithmic improvements

[0.14.0] - 2022-11-30

Formatting Changes + Bug Fixes

  • sqlfmt now supports {% materialization ... %} and {% call statement(...) %} blocks (#309).
  • sqlfmt now resets the SQL depth of a query after encountering an {% endmacro %}, {% endtest %}, {% endcall %}, or {% endmaterialization %} tag.
  • sqlfmt now supports create warehouse and alter warehouse statements (#312, #299).
  • sqlfmt now supports alter function and `drop func...
Read more

v0.19.1

13 Jul 21:39
b152085
Compare
Choose a tag to compare

sqlfmt CHANGELOG

All notable changes to this project will be documented in this file.

[Unreleased]

[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 in pyproject.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

[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
    that some_field and some_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

[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, as utf-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 to inherit, 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 pass Mode(fast=True) to any API method. The safety check is automatically bypassed if sqlfmt is run with the --check or --diff options. If the safety check fails, the CLI will include an error in the report, and the format_string API will raise a SqlfmtEquivalenceError, which is a subclass of SqlfmtError.

[0.14.3] - 2023-01-05

Formatting Changes + Bug Fixes

  • fixed a bug where very long lines could raise RecursionError (#343 - thank you @kcem-flyr!).

[0.14.2] - 2022-12-12

Formatting Changes + Bug Fixes

  • fixed a bug where nested {% set %} and {% call %} blocks would cause a parsing error (#338 - thank you @AndrewLane!).

[0.14.1] - 2022-12-06

Formatting Changes + Bug Fixes

  • sqlfmt now supports is [not] distinct from as a word operator (#327 - thank you @IgnorantWalking, @kadekillary!).
  • fixed a bug where jinja {% call %} blocks that called a macro that wasn't statement caused a parsing error (#335 - thank you @AndrewLane!).

Performance

  • sqlfmt runs finish in 20% less time due to algorithmic improvements

[0.14.0] - 2022-11-30

Formatting Changes + Bug Fixes

  • sqlfmt now supports {% materialization ... %} and {% call statement(...) %} blocks (#309).
  • sqlfmt now resets the SQL depth of a query after encountering an {% endmacro %}, {% endtest %}, {% endcall %}, or {% endmaterialization %} tag.
  • sqlfmt now supports create warehouse and alter warehouse statements (#312, #299).
  • sqlfmt now supports alter function and drop function statements (#310, #311), and Snowflake's create external function statements (#322)....
Read more

v0.19.0

08 Jun 21:58
71197ee
Compare
Choose a tag to compare

sqlfmt CHANGELOG

All notable changes to this project will be documented in this file.

[Unreleased]

[0.19.0] - 2023-06-08

Bug Fixes

  • Relative exclude paths defined in pyproject.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

[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
    that some_field and some_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

[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, as utf-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 to inherit, 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 pass Mode(fast=True) to any API method. The safety check is automatically bypassed if sqlfmt is run with the --check or --diff options. If the safety check fails, the CLI will include an error in the report, and the format_string API will raise a SqlfmtEquivalenceError, which is a subclass of SqlfmtError.

[0.14.3] - 2023-01-05

Formatting Changes + Bug Fixes

  • fixed a bug where very long lines could raise RecursionError (#343 - thank you @kcem-flyr!).

[0.14.2] - 2022-12-12

Formatting Changes + Bug Fixes

  • fixed a bug where nested {% set %} and {% call %} blocks would cause a parsing error (#338 - thank you @AndrewLane!).

[0.14.1] - 2022-12-06

Formatting Changes + Bug Fixes

  • sqlfmt now supports is [not] distinct from as a word operator (#327 - thank you @IgnorantWalking, @kadekillary!).
  • fixed a bug where jinja {% call %} blocks that called a macro that wasn't statement caused a parsing error (#335 - thank you @AndrewLane!).

Performance

  • sqlfmt runs finish in 20% less time due to algorithmic improvements

[0.14.0] - 2022-11-30

Formatting Changes + Bug Fixes

  • sqlfmt now supports {% materialization ... %} and {% call statement(...) %} blocks (#309).
  • sqlfmt now resets the SQL depth of a query after encountering an {% endmacro %}, {% endtest %}, {% endcall %}, or {% endmaterialization %} tag.
  • sqlfmt now supports create warehouse and alter warehouse statements (#312, #299).
  • sqlfmt now supports alter function and drop function statements (#310, #311), and Snowflake's create external function statements (#322).
  • sqlfmt better supports numeric constants (number literals), including those using scientific notation (e.g., 1.5e-9) and the unary + or - operators (e.g., +3), and is now smarter about when the - symbol is the unary negative or binary subtraction operator. (#321 - thank you @liaopeiyuan!).
  • fixed a bug where we added extra whitespace to the end of empty comment lines ([#319](https://github.com/tconb...
Read more

v0.18.3

31 May 20:51
69234e2
Compare
Choose a tag to compare

sqlfmt CHANGELOG

All notable changes to this project will be documented in this file.

[Unreleased]

[0.18.3] - 2023-05-31

  • 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!)
  • 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
    that some_field and some_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

[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, as utf-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 to inherit, 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 pass Mode(fast=True) to any API method. The safety check is automatically bypassed if sqlfmt is run with the --check or --diff options. If the safety check fails, the CLI will include an error in the report, and the format_string API will raise a SqlfmtEquivalenceError, which is a subclass of SqlfmtError.

[0.14.3] - 2023-01-05

Formatting Changes + Bug Fixes

  • fixed a bug where very long lines could raise RecursionError (#343 - thank you @kcem-flyr!).

[0.14.2] - 2022-12-12

Formatting Changes + Bug Fixes

  • fixed a bug where nested {% set %} and {% call %} blocks would cause a parsing error (#338 - thank you @AndrewLane!).

[0.14.1] - 2022-12-06

Formatting Changes + Bug Fixes

  • sqlfmt now supports is [not] distinct from as a word operator (#327 - thank you @IgnorantWalking, @kadekillary!).
  • fixed a bug where jinja {% call %} blocks that called a macro that wasn't statement caused a parsing error (#335 - thank you @AndrewLane!).

Performance

  • sqlfmt runs finish in 20% less time due to algorithmic improvements

[0.14.0] - 2022-11-30

Formatting Changes + Bug Fixes

  • sqlfmt now supports {% materialization ... %} and {% call statement(...) %} blocks (#309).
  • sqlfmt now resets the SQL depth of a query after encountering an {% endmacro %}, {% endtest %}, {% endcall %}, or {% endmaterialization %} tag.
  • sqlfmt now supports create warehouse and alter warehouse statements (#312, #299).
  • sqlfmt now supports alter function and drop function statements (#310, #311), and Snowflake's create external function statements (#322).
  • sqlfmt better supports numeric constants (number literals), including those using scientific notation (e.g., 1.5e-9) and the unary + or - operators (e.g., +3), and is now smarter about when the - symbol is the unary negative or binary subtraction operator. (#321 - thank you @liaopeiyuan!).
  • fixed a bug where we added extra whitespace to the end of empty comment lines (#319 - thank you @eherde!).
  • fixed an bug where wrapping unsupported DDL in jinja would cause a parsing error (#326 - thank you @ETG-msimons!). Also improved parsing of unsupported DDL and made false positives less likely.
  • fixed a bug where we could have unsafely run black against jinja that contained Python keywords and their safe alternatives (e.g., return(return_())).
  • fixed a bug where we deleted some extra whitespace lines (and in very rare cases, nonblank lines)
  • fixed a bug where Python recursion limits could cause incorrect formatting in rare cases

[0.13.0] - 2022-11-01

Formatting Changes + Bug Fixes

Read more

v0.18.2

31 May 02:18
6485747
Compare
Choose a tag to compare

sqlfmt CHANGELOG

All notable changes to this project will be documented in this file.

[Unreleased]

[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
    that some_field and some_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

[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, as utf-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 to inherit, 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 pass Mode(fast=True) to any API method. The safety check is automatically bypassed if sqlfmt is run with the --check or --diff options. If the safety check fails, the CLI will include an error in the report, and the format_string API will raise a SqlfmtEquivalenceError, which is a subclass of SqlfmtError.

[0.14.3] - 2023-01-05

Formatting Changes + Bug Fixes

  • fixed a bug where very long lines could raise RecursionError (#343 - thank you @kcem-flyr!).

[0.14.2] - 2022-12-12

Formatting Changes + Bug Fixes

  • fixed a bug where nested {% set %} and {% call %} blocks would cause a parsing error (#338 - thank you @AndrewLane!).

[0.14.1] - 2022-12-06

Formatting Changes + Bug Fixes

  • sqlfmt now supports is [not] distinct from as a word operator (#327 - thank you @IgnorantWalking, @kadekillary!).
  • fixed a bug where jinja {% call %} blocks that called a macro that wasn't statement caused a parsing error (#335 - thank you @AndrewLane!).

Performance

  • sqlfmt runs finish in 20% less time due to algorithmic improvements

[0.14.0] - 2022-11-30

Formatting Changes + Bug Fixes

  • sqlfmt now supports {% materialization ... %} and {% call statement(...) %} blocks (#309).
  • sqlfmt now resets the SQL depth of a query after encountering an {% endmacro %}, {% endtest %}, {% endcall %}, or {% endmaterialization %} tag.
  • sqlfmt now supports create warehouse and alter warehouse statements (#312, #299).
  • sqlfmt now supports alter function and drop function statements (#310, #311), and Snowflake's create external function statements (#322).
  • sqlfmt better supports numeric constants (number literals), including those using scientific notation (e.g., 1.5e-9) and the unary + or - operators (e.g., +3), and is now smarter about when the - symbol is the unary negative or binary subtraction operator. (#321 - thank you @liaopeiyuan!).
  • fixed a bug where we added extra whitespace to the end of empty comment lines (#319 - thank you @eherde!).
  • fixed an bug where wrapping unsupported DDL in jinja would cause a parsing error (#326 - thank you @ETG-msimons!). Also improved parsing of unsupported DDL and made false positives less likely.
  • fixed a bug where we could have unsafely run black against jinja that contained Python keywords and their safe alternatives (e.g., return(return_())).
  • fixed a bug where we deleted some extra whitespace lines (and in very rare cases, nonblank lines)
  • fixed a bug where Python recursion limits could cause incorrect formatting in rare cases

[0.13.0] - 2022-11-01

Formatting Changes + Bug Fixes

  • sqlfmt now supports delete statements and the associated keywords using and returning (#281).
  • sqlfmt now supports grant and revoke statements and all associated keywords (#283).
  • sqlfmt now supports create function statements and all associated keywords (#282).
  • sqlfmt now supports the explain keyword ([#280](https://g...
Read more

v0.18.1

10 May 22:41
2c6b05b
Compare
Choose a tag to compare

sqlfmt CHANGELOG

All notable changes to this project will be documented in this file.

[Unreleased]

[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
    that some_field and some_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

[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, as utf-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 to inherit, 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 pass Mode(fast=True) to any API method. The safety check is automatically bypassed if sqlfmt is run with the --check or --diff options. If the safety check fails, the CLI will include an error in the report, and the format_string API will raise a SqlfmtEquivalenceError, which is a subclass of SqlfmtError.

[0.14.3] - 2023-01-05

Formatting Changes + Bug Fixes

  • fixed a bug where very long lines could raise RecursionError (#343 - thank you @kcem-flyr!).

[0.14.2] - 2022-12-12

Formatting Changes + Bug Fixes

  • fixed a bug where nested {% set %} and {% call %} blocks would cause a parsing error (#338 - thank you @AndrewLane!).

[0.14.1] - 2022-12-06

Formatting Changes + Bug Fixes

  • sqlfmt now supports is [not] distinct from as a word operator (#327 - thank you @IgnorantWalking, @kadekillary!).
  • fixed a bug where jinja {% call %} blocks that called a macro that wasn't statement caused a parsing error (#335 - thank you @AndrewLane!).

Performance

  • sqlfmt runs finish in 20% less time due to algorithmic improvements

[0.14.0] - 2022-11-30

Formatting Changes + Bug Fixes

  • sqlfmt now supports {% materialization ... %} and {% call statement(...) %} blocks (#309).
  • sqlfmt now resets the SQL depth of a query after encountering an {% endmacro %}, {% endtest %}, {% endcall %}, or {% endmaterialization %} tag.
  • sqlfmt now supports create warehouse and alter warehouse statements (#312, #299).
  • sqlfmt now supports alter function and drop function statements (#310, #311), and Snowflake's create external function statements (#322).
  • sqlfmt better supports numeric constants (number literals), including those using scientific notation (e.g., 1.5e-9) and the unary + or - operators (e.g., +3), and is now smarter about when the - symbol is the unary negative or binary subtraction operator. (#321 - thank you @liaopeiyuan!).
  • fixed a bug where we added extra whitespace to the end of empty comment lines (#319 - thank you @eherde!).
  • fixed an bug where wrapping unsupported DDL in jinja would cause a parsing error (#326 - thank you @ETG-msimons!). Also improved parsing of unsupported DDL and made false positives less likely.
  • fixed a bug where we could have unsafely run black against jinja that contained Python keywords and their safe alternatives (e.g., return(return_())).
  • fixed a bug where we deleted some extra whitespace lines (and in very rare cases, nonblank lines)
  • fixed a bug where Python recursion limits could cause incorrect formatting in rare cases

[0.13.0] - 2022-11-01

Formatting Changes + Bug Fixes

  • sqlfmt now supports delete statements and the associated keywords using and returning (#281).
  • sqlfmt now supports grant and revoke statements and all associated keywords (#283).
  • sqlfmt now supports create function statements and all associated keywords (#282).
  • sqlfmt now supports the explain keyword (#280).
  • sqlfmt now supports BigQuery typed table and struct definitions and literals, like table<a int64, b bytes(5), c string>.
  • sqlfmt now supports variables like $foo as ordinary identifiers.

Features

  • ...
Read more

v0.18.0

19 Apr 17:10
972a97b
Compare
Choose a tag to compare

sqlfmt CHANGELOG

All notable changes to this project will be documented in this file.

[Unreleased]

[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
    that some_field and some_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

[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, as utf-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 to inherit, 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 pass Mode(fast=True) to any API method. The safety check is automatically bypassed if sqlfmt is run with the --check or --diff options. If the safety check fails, the CLI will include an error in the report, and the format_string API will raise a SqlfmtEquivalenceError, which is a subclass of SqlfmtError.

[0.14.3] - 2023-01-05

Formatting Changes + Bug Fixes

  • fixed a bug where very long lines could raise RecursionError (#343 - thank you @kcem-flyr!).

[0.14.2] - 2022-12-12

Formatting Changes + Bug Fixes

  • fixed a bug where nested {% set %} and {% call %} blocks would cause a parsing error (#338 - thank you @AndrewLane!).

[0.14.1] - 2022-12-06

Formatting Changes + Bug Fixes

  • sqlfmt now supports is [not] distinct from as a word operator (#327 - thank you @IgnorantWalking, @kadekillary!).
  • fixed a bug where jinja {% call %} blocks that called a macro that wasn't statement caused a parsing error (#335 - thank you @AndrewLane!).

Performance

  • sqlfmt runs finish in 20% less time due to algorithmic improvements

[0.14.0] - 2022-11-30

Formatting Changes + Bug Fixes

  • sqlfmt now supports {% materialization ... %} and {% call statement(...) %} blocks (#309).
  • sqlfmt now resets the SQL depth of a query after encountering an {% endmacro %}, {% endtest %}, {% endcall %}, or {% endmaterialization %} tag.
  • sqlfmt now supports create warehouse and alter warehouse statements (#312, #299).
  • sqlfmt now supports alter function and drop function statements (#310, #311), and Snowflake's create external function statements (#322).
  • sqlfmt better supports numeric constants (number literals), including those using scientific notation (e.g., 1.5e-9) and the unary + or - operators (e.g., +3), and is now smarter about when the - symbol is the unary negative or binary subtraction operator. (#321 - thank you @liaopeiyuan!).
  • fixed a bug where we added extra whitespace to the end of empty comment lines (#319 - thank you @eherde!).
  • fixed an bug where wrapping unsupported DDL in jinja would cause a parsing error (#326 - thank you @ETG-msimons!). Also improved parsing of unsupported DDL and made false positives less likely.
  • fixed a bug where we could have unsafely run black against jinja that contained Python keywords and their safe alternatives (e.g., return(return_())).
  • fixed a bug where we deleted some extra whitespace lines (and in very rare cases, nonblank lines)
  • fixed a bug where Python recursion limits could cause incorrect formatting in rare cases

[0.13.0] - 2022-11-01

Formatting Changes + Bug Fixes

  • sqlfmt now supports delete statements and the associated keywords using and returning (#281).
  • sqlfmt now supports grant and revoke statements and all associated keywords (#283).
  • sqlfmt now supports create function statements and all associated keywords (#282).
  • sqlfmt now supports the explain keyword (#280).
  • sqlfmt now supports BigQuery typed table and struct definitions and literals, like table<a int64, b bytes(5), c string>.
  • sqlfmt now supports variables like $foo as ordinary identifiers.

Features

  • sqlfmt is now tested against Python 3.11 (#242). Previous versions of sqlfmt are also compatible.
    with Python 3.11. When installed in 3.11, ...
Read more

v0.17.1

12 Apr 22:29
75a79f6
Compare
Choose a tag to compare

sqlfmt CHANGELOG

All notable changes to this project will be documented in this file.

[Unreleased]

[0.17.1] - 2023-04-12

[0.17.0] - 2023-02-24

  • 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, as utf-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 to inherit, 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 pass Mode(fast=True) to any API method. The safety check is automatically bypassed if sqlfmt is run with the --check or --diff options. If the safety check fails, the CLI will include an error in the report, and the format_string API will raise a SqlfmtEquivalenceError, which is a subclass of SqlfmtError.

[0.14.3] - 2023-01-05

Formatting Changes + Bug Fixes

  • fixed a bug where very long lines could raise RecursionError (#343 - thank you @kcem-flyr!).

[0.14.2] - 2022-12-12

Formatting Changes + Bug Fixes

  • fixed a bug where nested {% set %} and {% call %} blocks would cause a parsing error (#338 - thank you @AndrewLane!).

[0.14.1] - 2022-12-06

Formatting Changes + Bug Fixes

  • sqlfmt now supports is [not] distinct from as a word operator (#327 - thank you @IgnorantWalking, @kadekillary!).
  • fixed a bug where jinja {% call %} blocks that called a macro that wasn't statement caused a parsing error (#335 - thank you @AndrewLane!).

Performance

  • sqlfmt runs finish in 20% less time due to algorithmic improvements

[0.14.0] - 2022-11-30

Formatting Changes + Bug Fixes

  • sqlfmt now supports {% materialization ... %} and {% call statement(...) %} blocks (#309).
  • sqlfmt now resets the SQL depth of a query after encountering an {% endmacro %}, {% endtest %}, {% endcall %}, or {% endmaterialization %} tag.
  • sqlfmt now supports create warehouse and alter warehouse statements (#312, #299).
  • sqlfmt now supports alter function and drop function statements (#310, #311), and Snowflake's create external function statements (#322).
  • sqlfmt better supports numeric constants (number literals), including those using scientific notation (e.g., 1.5e-9) and the unary + or - operators (e.g., +3), and is now smarter about when the - symbol is the unary negative or binary subtraction operator. (#321 - thank you @liaopeiyuan!).
  • fixed a bug where we added extra whitespace to the end of empty comment lines (#319 - thank you @eherde!).
  • fixed an bug where wrapping unsupported DDL in jinja would cause a parsing error (#326 - thank you @ETG-msimons!). Also improved parsing of unsupported DDL and made false positives less likely.
  • fixed a bug where we could have unsafely run black against jinja that contained Python keywords and their safe alternatives (e.g., return(return_())).
  • fixed a bug where we deleted some extra whitespace lines (and in very rare cases, nonblank lines)
  • fixed a bug where Python recursion limits could cause incorrect formatting in rare cases

[0.13.0] - 2022-11-01

Formatting Changes + Bug Fixes

  • sqlfmt now supports delete statements and the associated keywords using and returning (#281).
  • sqlfmt now supports grant and revoke statements and all associated keywords (#283).
  • sqlfmt now supports create function statements and all associated keywords (#282).
  • sqlfmt now supports the explain keyword (#280).
  • sqlfmt now supports BigQuery typed table and struct definitions and literals, like table<a int64, b bytes(5), c string>.
  • sqlfmt now supports variables like $foo as ordinary identifiers.

Features

  • sqlfmt is now tested against Python 3.11 (#242). Previous versions of sqlfmt are also compatible.
    with Python 3.11. When installed in 3.11, sqlfmt no longer requires the tomli dependency.

[0.12.0] - 2022-10-14

Formatting Changes + Bug Fixes

  • DDL and DML statements (create, insert, grant, etc.) will no longer be formatted (#243).
    These statements were never supported by sqlfmt, and the existing algorithm produced bad formatting. Support for DDL and DML statements will be gradually added back in in future versions.
    For more information, see the tracking issue for DDL support.
  • BigQuery typed array literals like array<float64>[1, 2] are now supported, and spaces will no longer be inserted around < and > (#212).
  • SparkSQL-specific keywords tablesample, cluster by, distribute by, sort by, and lateral view are now supported by the polyglot dialect (#264).
  • pivot and unpivot are now supported as word operators, and will have a space between the keyword and the following parentheses.
  • values is now supported as an unterminated keyword; tuples of values will be indented from the values keyword if they span more than one line (#263).

[0.11.1] - 2022-09-17

Features

  • Any CLI option can now be configured using environmen...
Read more