What’s Changed
One of the biggest new features in this release is the support for SQLAlchemy and other "placeholder" templating within SQL queries. Check out the documentation on how to set it up.
This release also adds seven new rules. Get some help with your leading whitespace, semi-colon placement, inconsistent column references in GROUP BY/ORDER BY, and getting rid of RIGHT JOIN's among other useful lints with our new rules! See our rules documentation for more details.
On top of those, we have made loads of grammar improvements across many dialects, improvements to the dbt templater (including issues where sqlfluff fix would corrupt the code 😱), more fix routines, and lots more improvements.
🚀 Enhancements
- [many dialects] Implement generic placeholder templating #1887 @jacopofar
- [many dialects] Add support for SQLAlchemy templating #1878 @jacopofar
- Add DROP PROCEDURE statement to T-SQL #1921 @jpy-git
- TSQL dialect: fix index/tables creation options #1955 @tkachenkomaria244
- Add DROP TYPE statement to ANSI dialect #1919 @jpy-git
- Add INSERT INTO statements to Redshift Dialect #1896 @tdstark
- Added TABLESAMPLE support to Bigquery #1897 @WittierDinosaur
- Add [LEFT] ANTI and [LEFT] SEMI joins to the Spark3 dialect #1942 @jpy-git
- Parse UPDATE/INSERT within WITH clause #1889 @jpy-git
- Add OVERRIDING SYSTEM/USER VALUE to insert statement in postgres dialect #1869 @jpy-git
- Add support for DROP SCHEMA [IF EXISTS] name [ CASCADE | RESTRICT ] #1865 @gimmyxd
- Add CREATE TABLE Statement To Redshift #1855 @tdstark
- Add DROP TYPE statement in postgres dialect #1870 @jpy-git
- Add SEQUENCE NAME to postgres sequence options #1866 @jpy-git
- Added SET Statement to Postgres #1877 @WittierDinosaur
- Postgres: Allow use of quoted identifiers to ALTER TABLE OWNER TO #1856 @markpolyak
- Updates to COPY INTO grammar in Snowflake #1884 @WittierDinosaur
- Postgres & T-SQL: Drop Function #1924 @WittierDinosaur
- Add Expressions to SET syntax #1852 @tunetheweb
- Update DbtTemplater to use JinjaTracer #1788 @barrywhart
- L043 refinement: Add autofix for common use of CASE to fill NULL values. #1923 @jpy-git
- New Rule L050: No leading whitespace #1840 @jpy-git
- L050: updating to target jinja templates #1885 @jpy-git
- New rule L051 to forbid lone JOIN #1879 @jpy-git
- New Rule L052: Semi colon alignment #1902 @jpy-git
- New Rule L053: Remove outer brackets from top-level statements. #1916 @jpy-git
- New Rule L054: Inconsistent column references in GROUP BY/ORDER BY clauses. #1917 @jpy-git
- New Rule L055: Use LEFT JOIN instead of RIGHT JOIN. #1931 @jpy-git
- New Rule L056: 'SP_' prefix should not be used for user-defined stored procedures #1930 @jpy-git
- Tsql partition by multiple columns #1906 @jpers36
- Added bare functions to values clause #1876 @WittierDinosaur
- Remove unnecessary context section, from code and the docs #1905 @jacopofar
- L036 docstring refinements #1903 @jpy-git
- Add
exclude_rulesoption for the Simple API #1850 @tunetheweb - Tox improvements: Streamline development/testing environments. #1860 @jpy-git
- Add Tox publish commands #1853 @jpy-git
- Documentation: Change inheritance dialect example to Redshift #1900 @chwiese
- Remove failing requires.io badge #1898 @jpy-git
- [Snowflake] Allow naked AUTOINCREMENT #1883 @gordonhart
- Add support for curly brackets in SnowSQL ampersand variables #1901 @chwiese
- Add short form help option (-h) #1947 @jpy-git
- Remove plaintext API key from benchmark utility #1863 @jpy-git
- Add
skip_installto static analysis sections of tox.ini #1851 @jpy-git - Move typing_extensions from
requirements_dev.txttorequirements.txt#1956 @jpy-git
🐛 Bug Fixes
- Fix bug where "sqlfluff fix" deletes dbt "{% snapshot %}" line #1907 @barrywhart
- Fix subquery bug in L026 #1948 @jpy-git
- Fix bug where L041 was confused by L016's placement of newlines in the parse tree #1904 @barrywhart
- Fix progressbar artifacts within linter errors #1873 @adam-tokarski
- Correct Snowflake warehouse sizes #1872 @jpy-git
- Fixed Delimited() logic, added TSQL grammar #1894 @WittierDinosaur
- L036 refinement - FROM clause interaction #1893 @jpy-git
- Add missing chardet install in setup.py #1928 @jpy-git
- Fix misplaced TableAliasInfo in L031 documentation #1946 @jpy-git
- Fix broken link to external SQL style guide #1918 @kevinmarsh