All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- Support for the Teradata dialect Thanks @Katzmann1983!
- A much more detailed getting started guide in the docs.
- For the
parse
command, added the--profiler
and--bench
options to help debugging performance issues. - Support for the
do
command in the jinja templater. - Proper parsing of the concatenate operator (
||
). - Proper indent handling of closing brackets.
- Logging and benchmarking of parse performance as part of the CI pipeline.
- Parsing of object references with defaults like
my_db..my_table
. - Support for the
INTERVAL '4 days'
style interval expression. - Configurable trailing or leading comma linting.
- Configurable indentation for
JOIN
clauses. - Rules now have their own logging interface to improve debugging ability.
- Snowflake and Postgres dialects.
- Refactor of whitespace and non-code handling so that segments are less greedy and default to not holding whitespace on ends. This allows more consistent linting rule application.
- Change config file reading to case-sensitive to support case sensitivity in jinja templating.
- Non-string values (including lists) now function in the python and jinja templating libraries.
- Validation of the match results of grammars has been reduced. In production cases the validation will still be done, but only on parse and not on match.
- At low verbosities, python level logging is also reduced.
- Some matcher rules in the parser can now be classified as simple which allows them to shortcut some of the matching routines.
- Yaml output now double quotes values with newlines or tab characters.
- Better handling on hanging and closing indents when linting rule L003.
- More capable handline of multi-line comments so that indentation and line length parsing works. This involves some deep changes to the lexer.
- Getting violations from the linter now automatically takes into account of ignore rules and filters.
- Several bugfixes, including catching potential infinite regress during fixing of files, if one fix would re-introduce a problem with another.
- Support for
a.b.*
on top ofa.*
in select target expressions.
- Deprecated python 2.7 and python 3.4 which are now both past their maintenance horizon. The 0.2.x branch will remain available for continued development for these versions.
- Rule L003 is now significantly smarter in linting indentation with support for hanging indents and comparison to the most recent line which doesn't have an error. The old (more simple) functionality of directly checking whether an indent was a multiple of a preset value has been removed.
- Fixed the "inconsistent" bug in L010. Thanks @nolanbconaway.
- Updated logging of parsing and lexing errors to have more useful error codes.
- Changed parsing of expressions to favour functions over identifiers to fix the expression bug.
- Fixed the "inconsistent" bug in L010. Thanks @nolanbconaway.
- Moved where the
SELECT
keyword is parsed within a select statement, so that it belongs as part of the newly renamedselect_clause
(renamed from previouslyselect_target_group
). - Clarified handling of the
type
andname
properties of the BaseSegment class and it's children.name
should be specific to a particular kind of segment, andtype
should express a wider group. Handling of thenewline
,whitespace
andcomma
segments has been updated so that we use thetype
property for most use cases rather thanname
.
- Meta segments for indicating where things can be present in the parsed
tree. This is mostly illustrated using the
Indent
andDedent
segments used for indicating the position of theoretical indents in the structure. Several helper functions have been added across the codebase to handle this increase in the kinds of segments which might be encountered by various grammars. - Rule L016 has been added to lint long lines. In the
fix
phase of this rule, there is enough logic to try and reconstruct a sensible place for line breaks as re-flow the query. This will likely need further work and may still encounter places where it doesn't fix all errors but should be able to deal with the majority of simple cases. - BigQuery dialect, initially just for appropriate quoting.
- Added parsing of DDL statements such as
COMMIT
,DROP
,GRANT
,REVOKE
andROLLBACK
. Thanks @barrywhart. --format
option to theparse
command that allows a yaml output. This is mostly to make test writing easier in the development process but might also be useful for other things.- Parsing of set operations like
UNION
. - Support for the
diff-cover
tool. Thanks @barrywhart. - Enabled the
fix
command while usingstdin
. Thanks @nolanbconaway. - Rule to detect incorrect use of
DISTINCT
. Thanks @barrywhart. - Security fixes from DeepCover. Thanks @sanketsaurav.
- Automatic fix testing, to help support the newer more complicated rules.
- Interval literals
- Support for the
source
macro from dbt. Thanks @Dandandan - Support for functions with spaces between the function name and the brackets
and a linting rule
L017
to catch this. - Efficiency cache for faster pruning of the parse tree.
- Parsing of array notation as using in BigQuery and Postgres.
- Enable the
ignore
parameter on linting and fixing commands to ignore particular kinds of violations.
- A
--code-only
option to theparse
command to spit out a more simplified output with only the code elements. - Rules can now optionally override the description of the violation
and pass that back via the
LintingResult
.
- Bugfix, correct missing files in
setup.py
install_requires
section. - Better parsing of the not equal operator.
- Added more exclusions to identifier reserved words to fix cross joins.
- At verbosity levels 2 or above, the root config is printed and then any diffs to that for specific files are also printed.
- Linting and parsing of directories now reports files in alphabetical order. Thanks @barrywhart.
- Better python 2.7 stability. Thanks @barrywhart.
- Fixing parsing of
IN
/NOT IN
andIS
/IS NOT
.
- Bugfix, default config not included.
- Tweek rule L005 to report more sensibly with newlines.
- Rework testing of rules to be more modular.
- Fix a config file bug if no root config file was present for some values. Thanks @barrywhart.
- Lexing rules are now part of the dialect rather than a global so that they can be overriden by other dialects when we get to that stage.
- Templating support (jinja2, python or raw).
- Variables + Macros.
- The
fix
command is also sensitive to fixing over templates and will skip certain fixes if it feels that it's conflicted.
- Config file support, including specifying context for the templater.
- Documentation via Sphinx and readthedocs.
- Including a guide on the role of SQL in the real world. Assisted by @barrywhart.
- Documentation LINTING (given we're a linting project) introduced in CI.
- Reimplemented L006 & L007 which lint whitespace around operators.
- Ability to configure rule behaviour direclty from the config file.
- Implemented L010 to lint capitalisation of keywords.
- Allow casting in the parser using the
::
operator. - Implemented
GROUP BY
andLIMIT
. - Added
ORDER BY
using indexes and expressions. - Added parsing of
CASE
statements. - Support for window/aggregate functions.
- Added linting and parsing of alias expressions.
- Fixed a bug which could cause potential infinite recursion in configuration
- Changed how negative literals are handled, so that they're now a compound segment rather than being identified at the lexing stage. This is to allow the parser to resolve the potential ambiguity.
- Restructure of rule definitions to be more streamlined and also enable
autodocumentation. This includes a more complete
RuleSet
class which now holds the filtering code. - Corrected logging in fix mode not to duplicate the reporting of errors.
- Now allows insert statements with a nested
with
clause. - Fixed verbose logging during parsing.
- Allow the
Bracketed
grammar to optionally match empty brackets using the optional keyword.
- Python 3.8 Support!
- Moved some of the responsibility for formatted logging into the linter to mean that we can log progressively in large directories.
- Fixed a bug in the grammar where one of the return values was messed up.
- Added a
--exclude-rules
argument to most of the commands to allow rule users to exclude specific subset of rules, by @sumitkumar1209 - Added lexing for
!=
,~
and::
. - Added a new common segment:
LambdaSegment
which allows matching based on arbitrary functions which can be applied to segments. - Recursive Expressions for both arithmetic and functions, based heavily off the grammar provided by the guys at CockroachDB.
- An
Anything
grammar, useful in matching rather than in parsing to match anything.
- Complete rewrite of the bracket counting functions, using some centralised class methods
on the
BaseGrammar
class to support common matching features across multiple grammars. In particular this affects theDelimited
grammar which is now much simpler but does also require slightly more liberal use of terminators to match effectively. - Rather than passing around multiple variables during parsing and matching, there is now
a
ParseContext
object which contains things like the dialect and various depths. This simplifies the parsing and matching code significantly. - Bracket referencing is now done from the dialect directly, rather than in individual
Grammars (except the
Bracketed
grammar, which still implements it directly). This takes out some originally duplicated code. - Corrected the parsing of ordering keywords in and
ORDER BY
clause.
- Removed the
bracket_sensitive_forward_match
method from theBaseGrammar
. It was ugly and not flexible enough. It's been replaced by a suite of methods as described above.
- Tweak to the L001 rule so that it doesn't crash the whole thing.
- Fixed the errors raised by the lexer.
- Fixed which modules from sqlfluff are installed in the setup.py. This affects
the
version
command.
- Big Rewrite - some loss in functionality might be apparent compared to pre-0.1.0. Please submit any major problems as issues on github
- Changed unicode handling for better escape codes in python 2. Thanks @mrshu
- BIG rewrite of the parser, completely new architecture. This introduces
breaking changes and some loss of functionality while we catch up.
- In particular, matches now return partial matches to speed up parsing.
- The
Delimited
matcher has had a significant re-write with a major speedup and broken the dependency onSequence
. - Rewrite of
StartsWith
andSequence
to use partial matches properly. - Different treatment of numeric literals.
- Both
Bracketed
andDelimited
respect bracket counting. - MASSIVE rewrite of
Bracketed
.
- Grammars now have timers.
- Joins properly parsing,
- Rewrite of logging to selectively output commands at different levels
of verbosity. This uses the
verbosity_logger
method. - Added a command line
sqlfluff parse
option which runs just the parsing step of the process to better understand how a file is being parsed. This also has options to configure how deep we recurse. - Complete Re-write of the rules section, implementing new
crawlers
which implement the linting rules. Now with inbuilt fixers in them. - Old rules removed and re implemented so we now have parity with the old rule sets.
- Moved to using Ref mostly within the core grammar so that we can have recursion.
- Used recursion to do a first implementation of arithmetic parsing. Including a test for it.
- Moved the main grammar into a seperate dialect and renamed source and test files accordingly.
- Moved to file-based tests for the ansi dialect to make it easier to test using the tool directly.
- As part of file tests - expected outcomes are now encoded in yaml to make it easier to write new tests.
- Vastly improved readability and debugging potential of the _match logging.
- Added support for windows line endings in the lexer.
- Added a
sqlfluff fix
as a command to implement auto-fixing of linting errors. For now onlyL001
is implemented as a rule that can fix things. - Added a
rules
command to introspect the available rules. - Updated the cli table function to use the
testwrap
library and also deal a lot better with longer values. - Added a
--rules
argument to most of the commands to allow rule users to focus their search on a specific subset of rules.
- Refactor the cli tests to use the click CliRunner. Much faster
- Number matching
- Fixed operator parsing and linting (including allowing the exception of
(*)
)
- Much better documentation including the DOCS.md
- Fixed comma parsing and linting
- Added operator regexes
- Added a priority for matchers to resolve some ambiguity
- Added tests for operator regexes
- Added ability to initialise the memory in rules
- Refactor of rules to allow rules with memory
- Adding comma linting rules (correcting the single character matchers)
- Adding mixed indentation linting rules
- Integration with CircleCI, CodeCov and lots of badges
- Changed import of version information to fix bug with importing config.ini
- Added basic violations/file reporting for some verbosities
- Refactor of rules to simplify definition
- Refactor of color cli output to make it more reusable
- Longer project description
- Proper exit codes
- colorama for colored output
- Significant CLI changes
- Much improved output from CLI
- Initial Commit! - VERY ALPHA
- Restructure into package layout
- Adding Tox and Pytest so that they work