* First Commit with Table Options included in Create Table statement to allow for temporal tables
* Added Temporal Table Queries
* Updated code based on feedback and provided greater test coverage
---------
Co-authored-by: Danny Jones <51742311+WittierDinosaur@users.noreply.github.com>
This surrounds complex expressions with `()` before fixing a cast or
convert to a shorthand cast using the `::` operator. Without this
change, the cast would be applied to only part of the appropriate
expression.
fixes#4301
* Move ISSUE from Snwoflake reserved keywords to unreserved ones
* Add select statement to snowflake parsing test
* move test case to snowflake_select fixture
* Revert osmosis dbt templater for now
* Revert the osmosis implementation of the templater for now
* Fix broken test
* Fix coverage gaps
* More coverage fixes
* PR review
* PR review
Co-authored-by: Barry Hart <barry.hart@zoro.com>
Co-authored-by: Alan Cruickshank <alanmcruickshank@gmail.com>
* Allow empty string.
* Handle leading templated placeholder whitespace.
* add the test case
* edit the source string too
* combine multiple source fixes if given
* Fix test case
* lint and mypy
* yaml lint
* coverage
* Update src/sqlfluff/utils/reflow/reindent.py
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Include the filename in critical exceptions
* tweek docstrings to appease flake8
* Revert "tweek docstrings to appease flake8"
This reverts commit 7a231b7ff867c97f2695935f97192996e08fb6d7.
* pin pydocstyle to pre 6.2.0
* fixed l037
* better impl for codecov
* make mypy happy
* first attempt at dbt test
* make flake8 happy
Co-authored-by: Alan Cruickshank <alanmcruickshank@gmail.com>
* Fix some issues with Docker Compose environment
* Oops, wasn't setting the flag correctly?
* Set pip_pre = false
* Black
* Skip coverage checks for ruleslinting and doctests
Co-authored-by: Alan Cruickshank <alanmcruickshank@gmail.com>
* Implicit Indents Rebase
* add configuration for implicit
* mypy, linting and consistency
* linting
* Coverage and long line treatment of implicits.
* add docs
* doc linting
* coverage
* Update src/sqlfluff/utils/reflow/reindent.py
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* make sure that tests are the same
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Add .gitpod.yml
* Remove .gitpod.yml
* Tweak Coveralls
* Tweak base-path
* Trigger build
* Specify "--cov=" appropriate to each build
* Tweaks
* Tweaks
* Change .tox paths to src/sqlfluff paths
* Run patch_lcov.py from tox, not from ci-tests.yml
* Fail-safe the script
* Add debug message
* Do nothing if coverage file not found
* Only try and patch lines where path begins with ".tox"
* Move Coveralls coverage builds first so we get results sooner
* Revert "Move Coveralls coverage builds first so we get results sooner"
This reverts commit b5df02bf8f5210732cafe0c2d9db9c6dcc5d879c.
* PR review: more detailed docstring
* Add .gitpod.yml
* Try using Coveralls rather than Codecov
* Remove .gitpod.yml
* Remove .gitpod.yml
* Trigger build
* Can't use Coverlls container action on Windows
* Update to use documented approach with Coveralls
* Install coveralls "on demand" before running
* Add GitHub token to Coveralls command
* Add "--service=github"
* Switch to official GitHub action, re-enable 2-way parallelism for some test runs
* Convert coverage file to lcov format for Coveralls upload
* Output pytest coverage in lcov format
* Specify path-to-lcov: coverage.lcov
* Add back codecov upload
* Fix JSON parsing issue with diff-quality plugin
* Fix issue on Windows: Need to close file so SQLFluff can write to it
* Remove unneeded "mode" parameter
* Trigger build
* Trigger build
* Fix possible cause of intermittent build issue
* Disable parallel test runs for jobs that upload to codecov
* Undo coverage-related changes
* Trigger build
Co-authored-by: Barry Hart <barry.hart@zoro.com>
* Stop adding trailing os.sep if ignore file is on the root of the file system
* Replaced single quotes with doubles to pass linting test
* Replaced hard-coded Linux FS root with OS agnostic expression
* Made linting changes suggested by Black
* Included paretheses to isolate logic
* Trigger build
Co-authored-by: Babur Ayanlar <baa@client3873.office.ableton.com>
Co-authored-by: Alan Cruickshank <alanmcruickshank@gmail.com>
Co-authored-by: Barry Hart <barry.hart@zoro.com>
* Port dbt-osmosis templater changes to SQLFluff
* Ran Black on the file
* Get some tests working
* Remove some likely obsolete tests
* Pass CLI vars to dbt-osmosis
* Add osmosis.py to SQLFluff
* Fix CI issues
* flake8
* Only run doctests for SQLFluff core, not sqlfluff-templater-dbt
* Skip sqlfluff-templater-dbt when running doctests
* Move osmosis.py to sqlfluff-templater-dbt package
* Misspelled package name
* Remove support for dbt < 1.0
* Removing bits of dbt < 1.0
* Add missing package
* Get more tests working
* Fix issues with ephemeral model compilation
* Remove osmosis.py; was moved to osmosis/__init__.py
* Add back functions that shouldn't have been removed
* Fix project_dir issue
* Fix some broken tests
* Try a different way of resetting between tests
* Try and get tests working
* Try to fix broken tests
* Remove unneeded compile() function; use compile_node().node
* PR review
* Add Apache license note
* Update plugins/sqlfluff-templater-dbt/sqlfluff_templater_dbt/templater.py
* Add back code for handling db connection errors, also if project_dir not set
* Add missing dependencies
* Fix broken test
* Remove the fake db connection error; causes other tests to fail somehow
* Add Sponsors section with Datacoves
* PR review
* Add back the test__templater_dbt_handle_database_connection_failure test
* Fixes, tweaks to the CI checks (dbt Windows tests were failing intermittently with dbt 1.0)
* Tweak Python versions: 3.9 -> 3.10
* Run Black
* Fix some issues with dbt 1.4.0b1
* Trigger build
* Run Black
* Black
* Create missing constraints file
* Tweak version
* Tweaks due to dbt test weirdness
Co-authored-by: Barry Hart <barry.hart@zoro.com>
Co-authored-by: Alan Cruickshank <alanmcruickshank@gmail.com>
* map reindent lines
* Test empty line behaviour
* The meat of reindent + tests
* templated test
* cleaner fix
* another buggy test case
* Set up intended tests
* Add block uuids
* template tag cases and logic
* drive indent unit from config
* Sever link between L003 and L016
* First pass at L003 kinda running
* Fix broken test
* untaken indents tracking
* Alternative indentation algorithm
* associated indent dialect tweeks
* handle comment lines and join indents better
* make to ignoring certain types works
* first pass at new approach to hanging indents
* Check that the fixes work too.
* Refactor single indent and add hanging test cases
* more robust hanging indent treatment
* New reindent algorithm mostly works.
* WIP: test cases for new method
* Consolidate and tests
* WIP: It's not pretty but we're getting there.
* Revise comment lines
* update hanger tests
* progress
* whoop indent on maths works
* more maths tweeking
* Revise Templated Lines
not pretty but mostly working
* Untaken indents rigour and testing
* Skip lines and linting
* dialect and test tweeks
* Handle templated newlines and templated indents
* Remove remaining references to old config
* mypy linting and references
* more test updates
* handle other placeholders better
* handle is_templated better
* bugfix to indents near templated lines
* Tests for whitespace consuming tags
* Not tidy - but most of the way to lexer rebuild
* linting and begin refactor
* block uuids and tidying
* clearup and handle unrendered templates
* Tidy up
* mypy
* yaml lint
* handle zero length slices better
* remove too many warnings
* Handle source only fixes more gracefully
* typo
* Comment revision logic tweeks
* mypy
* stretching test cases for tags which consume whitespace.
* Reindent logging (ironically)
* Test case working (before consuming whitespace)
* Crawl test works for consumed whitespace
* closer - but not quite
* slice helpers and more detailed mid point patches
* Refine source and template slicing more.
* fix reflow tests
* Better fix patches for literals.
* Fix coercion of placeholder newlines.
* Fix starting pos marker issue
* Fix newline bug
* Edge case handling for semicolons
* Rework indents in exasol
* Add a note to future self
* tsql indentation test cases
* mypy
* Update tests
* Remove specific L003 tests
* fix positioning checks of L003
* fix one part of standard testing
* Better fix deduplication
* Tweek to missing line detection
* Another edge case
* fix edge case in dbt tests
* Squash another bug.
* ANOTHER edge case
* Nice error messages for reindent
* mypy
* docstring issues
* Rethink indents slightly
* prevent odd unused indent pairs
* fix last config test
* Coverage edits
* linting
* use more slice helpers
* a little more helper usage
* coverage
* Coverage and deduplication
* qualify the assertion
* More coverage
* remove unnecessary code path
* linting
* Remove unused section & more coverage
* Revert removal of whitespace slicing code
* Remove unused section
* Remove unused code path
* linting
* Remove some TODO notes and add better docstrings and tests
* Better fix for #3836
* mypy
* Add fix for #3988
* Apply suggestions from code review
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* skip multi-line templated elements
* Revise comment
* Update comment on anchor shuffle.
* another clearer comment
* Better newline comments.
* Add helper function for consumed whitespace
* linting
* Reindent refactor
* Linting.
* Remove SPOILERS
* Update src/sqlfluff/utils/reflow/elements.py
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* better comment
* First tidy prototype
* Move configurable line lengths.
* fix broken reference
* core tests pass
* better logging and first line detection
* Rip out old L016 logic
* add error and fail tests to pytest summary
* better logging in dbt tests
* Switch reflow buffer from LintFix to LintResult
* mypy
* fix reflow tests
* fix duplication
* fix test cases
* fix missing results
* fix L006 positioning tests
* sort out assignment operators
* mypy
* Correct more test cases
* Fix some merge issues
* More fixes > results
* revert changes to LintFix with description
* fix reindent test
* fix a merge bug
* more bad merge fixes
* Handle long comment lines
* attempt ignore comment clauses
* Fix the easy errors. Still got hard ones left.
* solve the key error problem
* Fix two tests and add more logging for others.
* Fix templated newline detection
* linting and mypy
* Fix config issues
* Deal with source character lengths.
* fix rules test
* don't indent more than we need to for now.
* linting
* result source and line length fixes
* Indexing and more bug fixes
* fix assertion error
* More fixes
* better comment clause handing
* deeper comment ignores
* Better templated comment handling
* Fix more erroneous test cases
* more line length changes
* linting
* linting
* even more position marker fiddling
* off by one error
* skip indents in calculating lengths
* block comment handling
* operator precedence
* More stretching test cases
* yamllint
* Tidy up comments and logging
* break apart some of the bigger functions
* mypy tweeks
* Solution and test for the multiline jinja bug.
* A diversion into breaking around clauses
* Coverage improvements
* remove test dupe
* coverage fix
* Apply suggestions from code review
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* More PR feedback.
* Apply suggestions from code review
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Formulate range expression properly
* reword config docs
* simpler looping
* move max line length
* Correct config spec for moved values
* Isolate and better test balance increment logic
* mypy fix
* Apply suggestions from code review
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* clarify comment
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* map reindent lines
* Test empty line behaviour
* The meat of reindent + tests
* templated test
* cleaner fix
* another buggy test case
* Set up intended tests
* Add block uuids
* template tag cases and logic
* drive indent unit from config
* Sever link between L003 and L016
* First pass at L003 kinda running
* Fix broken test
* untaken indents tracking
* Alternative indentation algorithm
* associated indent dialect tweeks
* handle comment lines and join indents better
* make to ignoring certain types works
* first pass at new approach to hanging indents
* Check that the fixes work too.
* Refactor single indent and add hanging test cases
* more robust hanging indent treatment
* New reindent algorithm mostly works.
* WIP: test cases for new method
* Consolidate and tests
* WIP: It's not pretty but we're getting there.
* Revise comment lines
* update hanger tests
* progress
* whoop indent on maths works
* more maths tweeking
* Revise Templated Lines
not pretty but mostly working
* Untaken indents rigour and testing
* Skip lines and linting
* dialect and test tweeks
* Handle templated newlines and templated indents
* Remove remaining references to old config
* mypy linting and references
* more test updates
* handle other placeholders better
* handle is_templated better
* bugfix to indents near templated lines
* Tests for whitespace consuming tags
* Not tidy - but most of the way to lexer rebuild
* linting and begin refactor
* block uuids and tidying
* clearup and handle unrendered templates
* Tidy up
* mypy
* yaml lint
* handle zero length slices better
* remove too many warnings
* Handle source only fixes more gracefully
* typo
* Comment revision logic tweeks
* mypy
* stretching test cases for tags which consume whitespace.
* Reindent logging (ironically)
* Test case working (before consuming whitespace)
* Crawl test works for consumed whitespace
* closer - but not quite
* slice helpers and more detailed mid point patches
* Refine source and template slicing more.
* fix reflow tests
* Better fix patches for literals.
* Fix coercion of placeholder newlines.
* Fix starting pos marker issue
* Fix newline bug
* Edge case handling for semicolons
* Rework indents in exasol
* Add a note to future self
* tsql indentation test cases
* mypy
* Update tests
* Remove specific L003 tests
* fix positioning checks of L003
* fix one part of standard testing
* Better fix deduplication
* Tweek to missing line detection
* Another edge case
* fix edge case in dbt tests
* Squash another bug.
* ANOTHER edge case
* Nice error messages for reindent
* mypy
* docstring issues
* Rethink indents slightly
* prevent odd unused indent pairs
* fix last config test
* Coverage edits
* linting
* use more slice helpers
* a little more helper usage
* coverage
* Coverage and deduplication
* qualify the assertion
* More coverage
* remove unnecessary code path
* linting
* Remove unused section & more coverage
* Revert removal of whitespace slicing code
* Remove unused section
* Remove unused code path
* linting
* Remove some TODO notes and add better docstrings and tests
* Better fix for #3836
* mypy
* Add fix for #3988
* Apply suggestions from code review
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* skip multi-line templated elements
* Revise comment
* Update comment on anchor shuffle.
* another clearer comment
* Better newline comments.
* Add helper function for consumed whitespace
* linting
* Reindent refactor
* Linting.
* Remove SPOILERS
* Update src/sqlfluff/utils/reflow/elements.py
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* better comment
* Switch reflow buffer from LintFix to LintResult
* mypy
* fix reflow tests
* fix duplication
* fix test cases
* fix missing results
* fix L006 positioning tests
* sort out assignment operators
* mypy
* Correct more test cases
* Fix some merge issues
* More fixes > results
* revert changes to LintFix with description
* fix reindent test
* fix a merge bug
* more bad merge fixes
* Fix comment bug on reindent
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* map reindent lines
* Test empty line behaviour
* The meat of reindent + tests
* templated test
* cleaner fix
* another buggy test case
* Set up intended tests
* Add block uuids
* template tag cases and logic
* drive indent unit from config
* Sever link between L003 and L016
* First pass at L003 kinda running
* Fix broken test
* untaken indents tracking
* Alternative indentation algorithm
* associated indent dialect tweeks
* handle comment lines and join indents better
* make to ignoring certain types works
* first pass at new approach to hanging indents
* Check that the fixes work too.
* Refactor single indent and add hanging test cases
* more robust hanging indent treatment
* New reindent algorithm mostly works.
* WIP: test cases for new method
* Consolidate and tests
* WIP: It's not pretty but we're getting there.
* Revise comment lines
* update hanger tests
* progress
* whoop indent on maths works
* more maths tweeking
* Revise Templated Lines
not pretty but mostly working
* Untaken indents rigour and testing
* Skip lines and linting
* dialect and test tweeks
* Handle templated newlines and templated indents
* Remove remaining references to old config
* mypy linting and references
* more test updates
* handle other placeholders better
* handle is_templated better
* bugfix to indents near templated lines
* Tests for whitespace consuming tags
* Not tidy - but most of the way to lexer rebuild
* linting and begin refactor
* block uuids and tidying
* clearup and handle unrendered templates
* Tidy up
* mypy
* yaml lint
* handle zero length slices better
* remove too many warnings
* Handle source only fixes more gracefully
* typo
* Comment revision logic tweeks
* mypy
* stretching test cases for tags which consume whitespace.
* Reindent logging (ironically)
* Test case working (before consuming whitespace)
* Crawl test works for consumed whitespace
* closer - but not quite
* slice helpers and more detailed mid point patches
* Refine source and template slicing more.
* fix reflow tests
* Better fix patches for literals.
* Fix coercion of placeholder newlines.
* Fix starting pos marker issue
* Fix newline bug
* Edge case handling for semicolons
* Rework indents in exasol
* Add a note to future self
* tsql indentation test cases
* mypy
* Update tests
* Remove specific L003 tests
* fix positioning checks of L003
* fix one part of standard testing
* Better fix deduplication
* Tweek to missing line detection
* Another edge case
* fix edge case in dbt tests
* Squash another bug.
* ANOTHER edge case
* Nice error messages for reindent
* mypy
* docstring issues
* Rethink indents slightly
* prevent odd unused indent pairs
* fix last config test
* Coverage edits
* linting
* use more slice helpers
* a little more helper usage
* coverage
* Coverage and deduplication
* qualify the assertion
* More coverage
* remove unnecessary code path
* linting
* Remove unused section & more coverage
* Revert removal of whitespace slicing code
* Remove unused section
* Remove unused code path
* linting
* Remove some TODO notes and add better docstrings and tests
* Better fix for #3836
* mypy
* Add fix for #3988
* Apply suggestions from code review
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* skip multi-line templated elements
* Revise comment
* Update comment on anchor shuffle.
* another clearer comment
* Better newline comments.
* Add helper function for consumed whitespace
* linting
* Reindent refactor
* Linting.
* Remove SPOILERS
* Update src/sqlfluff/utils/reflow/elements.py
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* better comment
* Switch reflow buffer from LintFix to LintResult
* mypy
* fix reflow tests
* fix duplication
* fix test cases
* fix missing results
* fix L006 positioning tests
* sort out assignment operators
* mypy
* Correct more test cases
* Fix some merge issues
* More fixes > results
* revert changes to LintFix with description
* fix reindent test
* fix a merge bug
* more bad merge fixes
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* feat: Add rule for space around parenthesis
* lint L071
* lint L071
* fix broken test ignoring rules
* fix broken test index out of range
* fix return type syntax
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
This test failed when I just ran `pytest`, but succeeded when I ran `pytest -vv`. This is because "select" only appeared in the output when the verbosity level was at least two. Felt like the simplest change to just double check the verbosity level of the test run before deciding to check for this regex match
* Bump to version 1.4.3
* Update CHANGELOG.md
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Remove duplicate text in CHANGELOG.md
* Renumber new rules 69,70 -> 67,68; add rule 68 to CHANGELOG.md
* Linkify release notes
* Rename rule classes for the new rules
* Rename rule in default_config.cfg
* Rename rules in test .yml files
Co-authored-by: barrywhart <barrywhart@users.noreply.github.com>
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
Co-authored-by: Barry Hart <barry.hart@zoro.com>
* Implement diff_quality_plugin using command-line rather than Python
* Linting
* Update diff-quality plugin tests
* Port dbt templater connection management changes from the other PR for this issue
* Fix Windows test failure
* Add support for "--options" (however, will require diff-quality changes to work)
* Add support for passing in pregenerated reports
* Tweak code to fix coverage gap
* Cache dbt adapters by project, not by adapter type, fix deprecation warning
* Trigger build
* Trigger build
* Avoid using subprocess in plugin tests -- does this avoid coverage checks hanging?
Co-authored-by: Barry Hart <barry.hart@zoro.com>
* local change
* fic typo
* add partition by clause for copy into location method
* support most of feactures for copy into location
* local change
* fic typo
* format with black
* generate yml files
* change format of sql files
* change format
* name change
* generate yml files
Co-authored-by: Charles He <charleshe@Charless-MBP.attlocal.net>
* Fix file encoding issue with the dbt templater on Windows
* Maybe fix encoding issue by using in_str rather than reading file ourselves
* Fix Windows line ending issue with new test
* Included underscore as valid initial character for ReferencedVariableNameSegment.
* Add test case for underscore variable
Co-authored-by: Greg Finley <gregory.finley@gmail.com>
* Support parallel linting when many individual files specified
* Add LintedDir to LintingResult
* Fix more tests
* Fix broken test
* Linter.lint_path() forward to Linter.lint_paths()
* Fix Windows tests (path separator)
* Fix issues with Windows tests
* Fix broken test
Co-authored-by: Alan Cruickshank <alanmcruickshank@gmail.com>
* enforce consistent syntax for SQL type casting
* fixed casting in case statements
* regenerated fixtures
* removed unused modules, reformatted and added better comments
* added fixes for multicast
* adjusted new_segment
* added test cases, renamed rule to 69
* added crawl_behaviour and updated functional
* fixed linting errors
* fixed crawl_behaviour
* added config for rule L069
* added support for functional cast_expression in L013
* skip L048 for cast_expression
* allow non standard type casting in L034 fixtures
* added allow_non_standard_type_casting config for rule L069, updated the documentations
* regenerated fixture for jinja templater
* added more test cases for rule L069
* config type hints
* skip teradata, updated documentation
* added test coverage for skipping teradata
* discarded config override in L034 tests
* added cast_expression to L034
* added support for different type casting style
* added tests
* Update src/sqlfluff/rules/L069.py
Adjusted case
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* added more tests for comments, fixed comments raised by @
barrywhart
* added more tests for comments, fixed comments raised by @
barrywhart
* fixing linting errors
* fixing linting errors
* regenerated test yaml files
* added more tests
* Update src/sqlfluff/dialects/dialect_ansi.py
Co-authored-by: Barry Pollard <barrypollard@google.com>
* Update src/sqlfluff/dialects/dialect_ansi.py
Co-authored-by: Barry Pollard <barrypollard@google.com>
* Update src/sqlfluff/dialects/dialect_ansi.py
Co-authored-by: Barry Pollard <barrypollard@google.com>
Co-authored-by: Bolaji Wahab <bolaji.wahab@adjust.com>
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
Co-authored-by: Barry Pollard <barrypollard@google.com>
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* local change
* fic typo
* add storage reference segment
* make snowflake copy_options supports both copy_into_location and copy_into_table
* local change
* fic typo
* change typo LiteralNumeric to NumericLiteralSegment
* generate yml files
* format with black
* fix the sql file format
* add copy_into_location_statement_segment
* partially support the format_type_options
* support distinguish between copy_into_location and copy_into_table
* local change
* fic typo
* fix format and generate yml files
* support storage_integration and encryption parameters
* fix parsing error
* generate yml files
* add comment
* local change
* fic typo
* reformat and generate yml
Co-authored-by: Charles He <charleshe@Charless-MBP.attlocal.net>
Co-authored-by: Charles He <charleshe@Charless-MacBook-Pro.local>
* adding new style for supporting flyway placeholder variables in sql
* add fixture for flyway style placeholder templating
* adding placeholder test for flyway_var style
* mandate flyway_var pattern be enclosed in curly brakcets always
* adding test__config__load_placeholder_cfg
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
The `get_rules` function in the plugin example template had a type
error. The function returns all the rule classes that are defined in
the plugin. The return type was incorrectly annotated as
`List[BaseRule]` which means a list of *instances* of `BaseRule` and not
classes derived from `BaseRule`. Making it `List[Type[BaseRule]]`
instead fixes the error.
For reference, the type error shown by pyright was:
```
Expression of type "list[Type[Rule_Example_L001]]" cannot be assigned to return type "List[BaseRule]"
...
"Type[type]" is incompatible with "Type[BaseRule]"
```
Fixes https://github.com/sqlfluff/sqlfluff/issues/3961
This adds code to identify column references that are part of a lambda
expression, and mark them as "standalone aliases" that are exempt from rule
L027. (I.e. they are allowed to be unqualified, because there is no further
way to qualify them.)
* Changing cwd temporarily on dbt manifest load
Co-authored-by: ssassi@sophilabs.com
* Add a test
* Try to fix broken test
* Fix test interaction
* Adjust dirs to try and pass on GitHub CI
* Profile full path to project and profiles dir
* Try again
* Skip test on Windows
* Fix crash in L042 on "UNION" or other "set" queries
* Working version (just needs tidying)
* Undo some unnecessary changes
* Remove more unnecessary changes
* Check for and fix missing whitespace after the CORRECT "FROM"
* Tidying
* DRY things up
* Tweak comments
* Break up compose_select() function, which was doing 2 unrelated things
* Revert "Break up compose_select() function, which was doing 2 unrelated things"
This reverts commit c9c81fc0ca23b0efc66557222015ae8983609d1f.
* Break up compose_select() again, more carefully
* Comments, docstrings
* Interim commit of refactoring
* Finish splitting up compose_select(), hopefully correctly this time
Co-authored-by: Alan Cruickshank <alanmcruickshank@gmail.com>
* Add indents and dedents around template loop
* mark indents as templated if inserted around templated sections
* docstring and linting
* Split apart elements_to_segments and rework placement of indents
* mypy and linting
* another test case and bug fix
* Apply suggestions from code review
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* condense position markers
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Map old configs to new configs
* more explicit logging
* linting
* more explicit test log config
* scrap testing logging output - too hard
* linting
* Update src/sqlfluff/core/config.py
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* updates to Spark SQL dialect for Delta Live Tables syntax
* final changes and test cases to sparksql dialect for adding DLT support
* update dialects rst doc file
clarify that Delta Lake expressions are implemented in SparkSQL
add reasoning why Databricks dialect is an alias instead of implemented outside of spark sql
* doclinting
* adding notes based on PR feedback to increase clarity
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
Co-authored-by: Alan Cruickshank <alanmcruickshank@gmail.com>
* fix(test): Return ParseExample namedtuple in get_parse_fixtures
This allows the usage of dot notation in
test/generate_parse_fixture_yml.py::_is_matching_criteria.
* fix(lint): Add docstring to ParseExample
Found via `codespell -S ./test/fixtures,./.mypy_cache,./.tox -L
inout,crate,fo,nd,falsy,get\'s`
Co-authored-by: Alan Cruickshank <alanmcruickshank@gmail.com>
* [issue_3644] provide custom DeprecatedOption
This is used for --disable_progress_bar. It's not covered with any tests yet, because not sure if this approach will defend itself.
* [issue_3644] provide some tests for DeprecatedOption
* [issue_3644] fix mypy warnings
Co-authored-by: Alan Cruickshank <alanmcruickshank@gmail.com>
* fix(redshift): Allow keywords in qualified references
* fix(redshift): Use ColumnReferenceSegment inherited from Postgres
A previous commit overrode ColumnReferenceSegment to allow keywords to
be used as qualified column references. However, this was a double
override and by deleting the existing override we achieve the same result.
* Rebreak for L007 & L019
* Validate configs, deprecate old ones and update tests
* Edge cases, logging, streamlining and bugs
- Correct test and typo in L052
- Remove error case.
- Resolve merge conflicts
- Fix doctest
- Remove reference to old config
- Fix doctest again
- Revert "Remove unused code"
- This reverts commit 4198e559e77d86c089b7e2335dab0da53fa89b64.
- Refine treatment of end-of-file
- Test cases and nits
- Two more stretching test cases
* Reclassify end_of_file to be blocky
* introduce strict and alone
* deduce indents and migrate L065
* Address better description in L019
* Apply suggestions from code review
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* anonymous tuple to frozen dataclass.
* reflow element segments to tuple
* Make end of loop more explicit
* while loops to for loops
* max to a for loop
* Clearer newline logic
* correction to while > for
* linting
* linting
* Partition fixes and solve issues
* More tests
* Apply suggestions from code review
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* mypy class typing
* Simplify _RebreakLocation
* validate no double whitespace
* Revert double whitespace check
* more explicit logging
* template loop bug fix
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Write up intent
* Logging and Config in context
* Reflow + tests
* PR Feedback
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* split apart respace_point
* Resolve merge conflicts on path_to
* Tests for respace
* Tests from #3762.
Co-authored-by: @mtsadler <michaeltsadler1@gmail.com>
* Handle alignment of aliases
* typo and more stretching test
* more test cases and fixes
* split out alignment logic into method
* Resolve single line line bug
* Remove unused code
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
Co-authored-by: @mtsadler <michaeltsadler1@gmail.com>
* Added failing test
* Added loop to check if each character is capitalizable (i.e. is a letter)
* Move test to fixture
* Apply suggestions from code review
Fix linter warnings
* Update src/sqlfluff/rules/L010.py
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
This is related to #356.
The previous fix of this issue (https://github.com/sqlfluff/sqlfluff/pull/722/files) ended up passing a parameter
to rule L027 for `value_table_function_aliases`, but not actually exempting these aliases from the rule.
It seems to me that the test case then passes because the result of the `unnest` function call is not counted as a table
reference, rather than passing because it is ok to use "unqualified" references for value tables (they are impossible
to qualify).
As such, I have added a new testcase `test_ignore_value_table_functions_when_counting_unqualified_aliases` which fails
on main, but passes with this fix.
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* ignore functions with more than one element ...
* push
* fix space
* limit this to just functions
* fix linitng
* fix lint
* fix linting and adjust two test cases
* really fix now
* improve the comment
* Update src/sqlfluff/rules/L010.py
Co-authored-by: Barry Pollard <barrypollard@google.com>
* Update test/fixtures/rules/std_rule_cases/L030.yml
Co-authored-by: Barry Pollard <barrypollard@google.com>
* Update test/fixtures/rules/std_rule_cases/L030.yml
Co-authored-by: Barry Pollard <barrypollard@google.com>
Co-authored-by: Felix Moeller <felix.moeller@noventum.de>
Co-authored-by: Barry Pollard <barrypollard@google.com>
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* MySQL: Implements remaining constraint parts of CREATE/ALTER TABLE
* add fixtures with check constraint
* Add more alter table queries
* Add queries with index_option in ALTER TABLE statements
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
Co-authored-by: Alan Cruickshank <alanmcruickshank@gmail.com>
* Fix syntax errors in Snowflake tests
* Update yaml files based on syntax fixes
* Update hash for modified yaml files
* Update yaml file based on syntax fixes
* Update hash in yaml based on syntax fixes
* Update yaml based on syntax changes
* Update hash of yaml
* Fix hash again
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* MySQL: Support variable assignments
treat assignment operator as L006 target (also affects exasol, tsql)
* MySQL: support assignment in expression
* MySQL: the := assignment operator is also permitted in SET syntax
https://dev.mysql.com/doc/refman/8.0/en/set-variable.html
* MySQL: add fixture for variable assignments
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Fix L061
* unfix some of my fix
* Typed matchers and ansi dialect
* Athena dialect
* Bigquery, Mysql & linting
* Exasol
* Postgres, Snowflake and Linting
* hive
* SparkSQL and TSQL
* rip name out of core.parser
* Rip out most of the remaining name references
* Fix test fails
* Tests for unparsable expectations
* PR Feedback
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Remove a chunk of name references
* Fix L061
* unfix some of my fix
* Update src/sqlfluff/core/parser/segments/base.py
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* extend grant syntax
* Empty-Commit
* move Grant Syntax for SF to SF dialect
* fix lint error
* remove redundant code
Co-authored-by: Halyna Tsekhmistro <halyna.tsekhmistro@health-union.com>
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* add Alter Pipe syntax for snowflake dialect
* close code review comments
* close code review comment for Prefix
* regenerate alter pipe fixture
Co-authored-by: Halyna Tsekhmistro <halyna.tsekhmistro@health-union.com>
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* BigQuery: Parse WEEK(<WEEKDAY>) in date_part
* Fixed the test by replacing invalid queries with valid queries
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* extend SF dialect for File Format statements
* close code review comments
* refactoring
* fix lint error and refactoring code
Co-authored-by: Halyna Tsekhmistro <halyna.tsekhmistro@health-union.com>
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Add a file size check in bytes
* extend the test to get better coverage
* Update src/sqlfluff/core/templaters/base.py
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Update src/sqlfluff/core/templaters/base.py
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Add .gitpod.yml
* Add "# pragma: no cover" to work around sporadic, spurious coverage failure
* Remove added file
Co-authored-by: Barry Hart <barry.hart@zoro.com>
Co-authored-by: Alan Cruickshank <alanmcruickshank@gmail.com>
Adds usage examples to the main -h output covering the use and placement
of the `--dialect`, `--rules`, and `--templater` options.
Also amends the error output when a required `--dialect` option is
absent to explain how to specify a dialect on the command line.
Co-authored-by: James Dominy <james.dominy@wpengine.com>
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Add .gitpod.yml
* When ignore=templating and fix_even_unparsable=True, provide defaults for missing vars
* Remove accidentally added file
* PR review, add magic methods
* Tweak
* Comments
* Add comment
* Handle missing macro files
* Handle UndefinedError, add logging
* Fix broken tests
* Tweak
* Tweaks
* Fix broken tests by splitting Undefined into two distinct classes
* Fix broken test
* Address missing coverage, remove some code that reports undefined vars when ignore=templating
* Remove unused function, avoid infinite recursion
* Add "no cover" to some unrelated code
* Move & improve comment
* Unary plus and minus
* Fix some issues, correctly handle use of Jinja default() filter
* Treat missing or undefined templates as their names
* Update src/sqlfluff/core/config.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Add documentation on the new behavior
* Fix some doc markdown / punctuation issues
Co-authored-by: Barry Hart <barry.hart@zoro.com>
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Add child type set property
* Seperate rule context out into new module
* Basic crawlers and simple RootCrawler case
* Seeker Crawler
* Implement crawlers in 65 & 66
* 61, 61 & 64 to new crawlers
* Add pass filter to Segment Crawler
* Implement raw stack and some of the rules which use it.
* fix issue with L004
...and linting
* coverage
* Update src/sqlfluff/rules/L060.py
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Update src/sqlfluff/core/parser/segments/base.py
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Update src/sqlfluff/core/rules/crawlers.py
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Update src/sqlfluff/core/rules/crawlers.py
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* switch to abstract base class
* Add crawl behaviour for a bunch of easier rules
* More rule fixes
* Big simplification of L039
+ Don't duplicate the work of L001
* Bring in L006 and dependents
* Bring in L010 and dependents [except L063]
* increase logging level for failing test
* Don't set crawl behaviour for L063 - not ready yet
* migrate L026
* mypy
* bring in rule L007
* Refactor L010 and L063 to allow new structure.
* fix L063
* metaclass goodness
* linting, coverage and test fixes.
* migrate rule L052
* PR feedback
* Migrate L053
* Move trigger segment of L052
* Migrate L046
* Migrate L008
* Migrate L019
* coverage
* Migrate the last rules
* Strip out old CrawlBehaviour
* remove raw_segment_pre
* update example & test rules
* PR edits
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
Update src/sqlfluff/core/parser/segments/base.py
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
Update test/core/parser/segments_base_test.py
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
Update src/sqlfluff/rules/L053.py
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
Update src/sqlfluff/core/rules/context.py
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
Update src/sqlfluff/core/rules/context.py
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
Update src/sqlfluff/core/rules/crawlers.py
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
Update src/sqlfluff/rules/L010.py
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* PR Feedback
* linting
* nope - revent change to L052
* Update src/sqlfluff/rules/L039.py
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* BigQuery: Fix parsing parameterized data types
* Replace the type in a comment with a supported one
* Make the param[, ...] part more specific
* Extend DatatypeSegment to support parameterized data types
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Switch to matchable types
* more type hints
* Tighten type hints
* unquote matchable type
* clarify comment
* PR feedback improvements
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Test against dbt-core 1.3
* Add check for dbt>=1.3
* Use the correct dbt_utils fixture
* Install dbt-postgres 1.3.0 prereleases
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
Co-authored-by: Alan Cruickshank <alanmcruickshank@gmail.com>
* Remove name from bracket matching
... and adjust L053
* Remove some symbol names
* Adjust failing rules
* Generalise a few more segments
* Update dialect fixtures
* fix the api example
* Handle some more dialects
* More dialect changes
* more rule and dialect fixes
* update dialect yamls
* More dialect literals and identifiers
* linting
* fix L054
* update yamls
* Fix a bunch of rules
* Fix L034 and L049
* Fixes for L026
* More rule fixes
* Fix Merge
* Strip out name kwargs and fix test fixtures.
strip out some more names
Strip a LOT more names
linting
* Fix typo
* Fix yaml
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* L028, L032: Fix bug where fixes were copying templated table names
* Fix unrelated Black formatting issue
* Fix crash when source is None
* PR review: add new test case
* L042: Do not flag or fix correlated subqueries
* Add "# pragma: no cover" for missed coverage
* Remove unnecessary old code
* Fix issue 3598, where L042 can "fix loop" forever
* Fix unrelated Python linting error
* Add missing rule config for new test cases
* For issue 3598, flag but do not attempt to fix
* Allow configuration of processes from config
* linting
* mypy update
* Allow zero to mean all cpus
* Update doc notes.
* test coverage for proces logic
* test the 1 cpu case
* linting
* no cover for process formatting
* Add intermediate reposition and test
* mypy fix
* tidy up the failing dbt test
* Use UUIDs for matching
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* option to show errors on fix
* option to show errors on fix
* Update src/sqlfluff/cli/commands.py
* Update test/cli/commands_test.py
* fix flake issues
* change _ to -
* fix tests
* fix tests
* Fix line length lint error
* Fix Black errors
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
Fixes issue #3651.
Previously, the first argument to the `convert` redshift function was
interpreted as a column reference rather than a data type. This could
cause rule L027 to fail since the data type wasn't qualified with a
table name even though that doesn't make sense. This adds explicit
handling for `convert` to eliminate that issue.
* fix in AlterTableStatementSegment
* add delta contraints to AlterTableStatementSegment
* black & yml files
* add link to Delta docs
* replace Anything with ExpressionSegment
* L057: In BigQuery, allow hyphens by default
* Allow hyphens in BigQuery
* Add test case as suggested in PR review
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
* BigQuery: Better support hyphened projects
* Improve handling of BigQuery hyphenated table names
* Rework iter_raw_references()
* Add missing .yml file
* Remove redundant .sql and .yml files
* Add a test for BigQuery iter_raw_references()
* Revert "Remove redundant .sql and .yml files"
This reverts commit 1252d41f09dc873c11d996e9bbb8bc9f6ce76117.
* Remove my test files, since we have the ones from the original PR
* Refactor/simplify iter_raw_references()
Co-authored-by: Greg Finley <gregory.finley@gmail.com>
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
* Modify .simple() to track loops in grammars
* sort dependencies of BaseExpressionElementGrammar
* rationalise literals in ansi
* knockon changes in athena
* bigquery implications
* hive knockon
* postgres knockon
* simplify tsql dependency
* odd change to teradata?
* make the object literal segment less flat.
* mypy
* re-add datatypes in Expression D
* readjust expression
* Dialect Crumbs
* More mypy
* Revert one of the changes with better comment
* update yamls
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Updated developingplugins.rst Added plugin support
Added support for custom implemented rules
* Update developingplugins.rst
-added comma
-added line space
* Update docs/source/developingplugins.rst
* Linting fixes
Co-authored-by: Barry Pollard <barrypollard@google.com>
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Grammar to Segment
* Copy the original segment in Bracketed and position segments
* Update src/sqlfluff/dialects/dialect_ansi.py
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Update src/sqlfluff/core/parser/segments/base.py
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Fix the things which broke on merge
* revert more changes
* unparsable cte test
* add parsed case from clickhouse
* try removing other workarounds 1
* simplify grammars
* remove more workarounds
* Remove more workarounds
* linting
* appease mypy
* Update yaml cases
* Update test/fixtures/dialects/clickhouse/cte_columns.sql
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Update src/sqlfluff/core/parser/segments/base.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* remove unnecessary comment
* coverage
* typing for _position_segments
* add warning on nested ephemerals
* demonstrate cte bug fixed
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Simplify lint fixing (prep for source fixes)
* Split apart fix_string into smaller functions
* linting
* Bring back in some checks which *are*used
* linting
* Add some no cover elements
* linting
* fix incorrect references
* linting
* Fixing test harness
* More complicated tests
* Mechanics and tests for source fixes
* Add test cases and get most to pass.
* Source fixes - working for rule test cases
* linting
* coverage
* mypy fixes
* Update src/sqlfluff/core/parser/segments/base.py
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Update src/sqlfluff/core/parser/segments/base.py
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Update src/sqlfluff/core/parser/segments/base.py
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Update src/sqlfluff/core/parser/segments/raw.py
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* More comments and test an empty tag fix
* Linting
* test fixes
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* collate in table column
* Create collation
* delimited implies optional I guess
* Add note
* remove more optionals
* better tests
* Smush into a single test using UNIQUE instead of PK
* More tests
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Postgres: Small fixes to COMMENT ON
* Update src/sqlfluff/dialects/dialect_postgres.py
* Update src/sqlfluff/dialects/dialect_postgres.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Modify at_sign lexer and add parser to handle MyQL system variables + provide fixtures for validation.
* Improve at_sign lexer.
$ sign is now supported, and a `.` cannot be at the start/end of a variable name.
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
In cases where the CTE has a column list, we don't need an alias for
columns. This checks if the select has a `common_table_expression`
parent and if that parent has a `cte_column_list` child. In that case,
it doesn't complain about a missing alias.
Fixes#3558
* Simplify lint fixing (prep for source fixes)
* Split apart fix_string into smaller functions
* linting
* Bring back in some checks which *are*used
* linting
* Add some no cover elements
* linting
* fix incorrect references
* linting
This fixes#3569 where rule L022 wants to put a new line after the
closing parenthesis of the CTE argument list. It seems like the
postgres dialect needed to be updated to match the ansi one as part of
* L016: ignore_comment_clauses not working for postgres dialect
* Regenerate Postgres YAML files after dialect change
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
* Rework L046 ready for the fix routines
* linting
* shorten long lines
* mypy fixes
* Revert many changes (I now understand)
* correct the type selectors for L046
* revert memory changes
* Add doctests and CI
* linting
* Add better handling for SQLFluffUserError when running core cli commands
* Update to context manager
* revert kwargs back to args where args were before
* Add tests
* L025 should not remove aliases from derived queries
* Add back removed test case, now as pass rather than fail
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
* Fix issue where "--nocolor" is ignored
* Fix broken tests
* Fix broken tests
* Fix coverage issue by reusing (not copying) code
* Add a test for the specific issue reported by the user
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
* allow final modifier in clickhouse dialect
* Update src/sqlfluff/dialects/dialect_clickhouse.py
Co-authored-by: Barry Pollard <barrypollard@google.com>
* Update test/fixtures/dialects/clickhouse/final.sql
Co-authored-by: Barry Pollard <barrypollard@google.com>
Co-authored-by: Barry Pollard <barrypollard@google.com>
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Add a new configuration for L018 to ignore indentations
* Fix lint error
* Fix mypy problem
* Change the meaning of L018 to check only newline, not indentation
* Add combo tests
* Fix tests according to comments
* update terminator grammar for preceding clauses
* test case for 3484
* updates for adding GroupByClauseTerminatorGrammar
* update terminator for match_grammar in ansi
* updates for adding HavingClauseTerminatorGrammar
* Fix L025 false positive for tsql VALUES clause
* Tidying
* Rename variable -- old name was wrong
* Add "no cover"
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
This means that the regexes are only compiled once rather than everytime
a `RegexParser` is evaluated.
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Add `MultiStringParser` to match a set of strings
This parser takes a collection of strings and returns a match if any of
them are found. This is more performant than implementing this through
the `RegexParser` as a hash matching route can be taken.
* Perform `.upper()` in `__init__`
* Check `is_code` first for performance
* Use `super` to initialize object
* Add `MultiStringParser` simple test
* Implement `BaseParser` abstract class
* Avoid calling `.upper()` when matching
* Avoid `list` creation at every `simple` call
* Remove more `RegexParser`s
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* MySQL: Support LOAD DATA
* code golf
* Revert "code golf"
This reverts commit 2c39e4256dbbe4df1709e326f69f71c5413cad0f.
You could have both things
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Move dictionary definition outside the `for`
The definition of `macro_ctx` inside the `for` loop basically kills the feature of "comma-separated list of `.sql` or folders" (see [docs](https://docs.sqlfluff.com/en/stable/configuration.html))
If a folder has multiple entries, only the last one will prevail because the `macro_ctx = {}` is being executed.
Also, the `return` value of the function is a variable defined in an inner scope, which is not a good practice.
* Add missing tests
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* convert to delta command support
* Update src/sqlfluff/dialects/dialect_sparksql.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* support for syntax to create manifest files
* pr feedback
* Update src/sqlfluff/dialects/dialect_sparksql.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Update src/sqlfluff/dialects/dialect_sparksql_keywords.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* formatting and refresh YMLs
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* L045: Add handling for nested CTEs
* Also handle nested queries
* Add another nested query test case
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
* Bump to version 1.0.0
* Update to stable
* Fix util script
* Update changelog
* fix util script and update changelog
* Add a bit of prose to announce the release
* update util script to add spaces in version headings
* More docs update for stable release
* update changelog with more recent changes
* Update changelog with last PR
Co-authored-by: alanmcruickshank <alanmcruickshank@users.noreply.github.com>
Co-authored-by: Alan <alanmcruickshank@gmail.com>
* Migrate release script to Python
* progress
* regex
* Rewrite existing what's changed
* Find potential new contributors
* Start new contributors
* Get owner from env variable
* Note about safe to rerun
* Get correct new contribs for net new
* WIP
* Fix new contributors when rerunning
* add as dev requirement
* Reword doc
* Abort GHA if branch already exists
* Instructions on running locally
* Update CONTRIBUTING.md
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Update JinjaAnalyzer and JinjaTracer to handle {% block %}
* Add test case
* Comments
* PR review
* Add a more complex test case
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Update warning for parsing errors
* add test
* test implicit dialect as well
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* L027: Fix false positives by reverting PR #2998 (Check table aliases exist), issue #2992
* Add test cases from user issues
* Add another test case from another user issue
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
* L036: Make wildcard behavior configurable
* Revert these changes now that the default behavior is "single"
* PR review, undo irrelevant change
* Add "@document_configuration" decorator to L036
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
* Unpin coverage now issue with 6.2 and 6.3 has been resolved
* Just exclude 6.3
* Update requirements_dev.txt
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* L045: handle `UPDATE` statements with CTEs
* Add no cover for code that's not longer tested
* Review feedback
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* L027: Add support for `ignore_words`
* Update test/fixtures/rules/std_rule_cases/L027.yml
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Add support for ALTER SCHEMA to PostgreSQL (and therefore to Redshift) - Issue 3320
* add newline at end of file
* dang. removed stupid spaces.
* Update test/fixtures/dialects/postgres/postgres_alter_schema.sql
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Update src/sqlfluff/dialects/dialect_postgres.py
remove blank line
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Add Redshift alter schema test
* add quota grammar
* yml for redshift tests
* && and XOR initial commit
* new line
* Fix linting issues
* Barry's AndKeywordSegment override idea
* Expression_C_Grammar -> Expression_A_Grammar and ramifications
* dang. Uncomment first line of select_boolean_operators.sql
* reflect requests from latest review
* Update src/sqlfluff/dialects/dialect_mysql.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* implement requests from latest review
* typo in NotGrammar
* AndKeywordSegment added back plus AndOperatorGrammar, OrOperatorGrammar, NotOperatorGrammar
* initial checkin of mysql keywords
* Apply suggestions from code review
* reserved keywords
* updates tests to handle new reserved words
* improve comments
* changes and tests for issue-1675
* updates requested in PR
* Update src/sqlfluff/dialects/dialect_mysql.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Add support for ALTER SCHEMA to PostgreSQL (and therefore to Redshift) - Issue 3320
* add newline at end of file
* dang. removed stupid spaces.
* Update test/fixtures/dialects/postgres/postgres_alter_schema.sql
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Update src/sqlfluff/dialects/dialect_postgres.py
remove blank line
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Add Redshift alter schema test
* add quota grammar
* yml for redshift tests
* && and XOR initial commit
* new line
* Fix linting issues
* Barry's AndKeywordSegment override idea
* Expression_C_Grammar -> Expression_A_Grammar and ramifications
* dang. Uncomment first line of select_boolean_operators.sql
* reflect requests from latest review
* Update src/sqlfluff/dialects/dialect_mysql.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* implement requests from latest review
* typo in NotGrammar
* AndKeywordSegment added back plus AndOperatorGrammar, OrOperatorGrammar, NotOperatorGrammar
* Apply suggestions from code review
* changes and tests for issue-1675
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* L065: Add rule for set operators surrounded by newlines
* Handle cases where Whitespace segment not accessable
* Fix mypy and lint
* Fix indentation via L003
* Add clarifying comment about `tsql`
* Workaround for mypy
* Update src/sqlfluff/rules/L065.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* L064: Add initial support for partially templated quoted literals
* Add more test cases
* Make mypy happy
* Fix review comments
* Refine logic to check for quotes inside templates
* Update src/sqlfluff/rules/L064.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Add support for ALTER SCHEMA to PostgreSQL (and therefore to Redshift) - Issue 3320
* add newline at end of file
* dang. removed stupid spaces.
* Update test/fixtures/dialects/postgres/postgres_alter_schema.sql
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Update src/sqlfluff/dialects/dialect_postgres.py
remove blank line
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Add Redshift alter schema test
* add quota grammar
* yml for redshift tests
* && and XOR initial commit
* new line
* Fix linting issues
* Barry's AndKeywordSegment override idea
* Expression_C_Grammar -> Expression_A_Grammar and ramifications
* dang. Uncomment first line of select_boolean_operators.sql
* reflect requests from latest review
* Update src/sqlfluff/dialects/dialect_mysql.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* implement requests from latest review
* typo in NotGrammar
* AndKeywordSegment added back plus AndOperatorGrammar, OrOperatorGrammar, NotOperatorGrammar
* Apply suggestions from code review
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* GitHub Action to set version number
* Mention that it creates a branch
* Remove testing lines
* create pull request
* Start Changelog entry
* Update job name in CONTRIBUTING.md
* remove redundant info
* Update .github/workflows/create-release-pull-request.yaml
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Update .github/workflows/create-release-pull-request.yaml
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Update .github/workflows/create-release-pull-request.yaml
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Start Of Releases line
* Bump to version 0.13.2
* Run release notes on any fork
* skip PR for now
* list releases
* auth
* echo stuff
* chop
* Revert "skip PR for now"
This reverts commit fdb9cdfb19245173ce0e3b548f1e51809e8ac815.
* Print the stuff to the CHANGELOG
* no parens
* try echo
* missing dollar
* Random change
* try writing to a temp file
* try writing to a file
* try more stuff
* better new-lining
* revert everything back
* github token as env
* Add blank sections
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
Co-authored-by: greg-finley <greg-finley@users.noreply.github.com>
* GitHub Action to set version number
* Mention that it creates a branch
* Remove testing lines
* create pull request
* Start Changelog entry
* Update job name in CONTRIBUTING.md
* remove redundant info
* Update .github/workflows/create-release-pull-request.yaml
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Update .github/workflows/create-release-pull-request.yaml
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Update .github/workflows/create-release-pull-request.yaml
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Start Of Releases line
* Update .github/workflows/create-release-pull-request.yaml
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Add support for ALTER SCHEMA to PostgreSQL (and therefore to Redshift) - Issue 3320
* add newline at end of file
* dang. removed stupid spaces.
* Update test/fixtures/dialects/postgres/postgres_alter_schema.sql
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Update src/sqlfluff/dialects/dialect_postgres.py
remove blank line
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Add Redshift alter schema test
* add quota grammar
* yml for redshift tests
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* MySQL: Added support for multiple variables in SET statement.
* Change SET statement to match Snowflake dialect.
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* make Getting Started consistent with README.md (add dialect, update output)
* Linting fixes
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Hive: support cluster, distribute, sort by
* add testcase
* Apply tunetheweb's review
* Make match_grammar as copy of origin not reference
* Apply review, Fix ORDER as Sequence(ORDER, BY)
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Adding Typeform and videoask into inthewild.rst
From Typeform, we would like to add our use case in your docs and thank you for this great tool :)
* Linting and grammar fixes
* Remove trailing spaces
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Allow various quotings
* Allow combinations with at sign
* SingleIdentifierSegment class
* Fix type label
* Update src/sqlfluff/dialects/dialect_mysql.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Update src/sqlfluff/dialects/dialect_mysql.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Keep SessionVariableNameSegment as a singleton
* Add references back
* ObjectReferenceSegment
* Move function
* Extend the match_grammar
* Redundant comment
* Disallow second gap
* Update src/sqlfluff/dialects/dialect_mysql.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Extend RoleReferenceSegment
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Add .gitpod.yml
* L007: An operator on a line by itself is okay
* Remove accidentally added file
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
* Bug fix: L036 handle single-column SELECT with comment on same line as SELECT
* Update docstring, add test case for the bug
* Progress
* Report lint warning but don't try to autofix
* Add more details about why autofixing is tricky
* Fix failing test
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Add CreateFileFormatSegment, CSV Format Type Options
* Swapping to AnyNumberOf()
* Add other file formats, complete create file format
* Move TYPE to Parameters, Add tests, Remove old class
* Big refactor, create tests
* Resolve merge conflicts fully
* Update Regex and String Parsers
* test fixtures
* Remove commented out code
* Remove artefact, ugh
* Update src/sqlfluff/dialects/dialect_snowflake.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Remove raw string
* Generate yml fixtures
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Add Db2 for i dialect
* revert CHANGELOG changes
* switch to generic Db2 to target all versions
* fix wrong dialect
* renaming files/folders from db2fori to db2
* generate yml file
* change url for db2 and other fixes
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Enhance apply_fixes() to automatically fix violations of can_start_end_non_code
* Refactor check for start/end non-code
* Move code/meta check to new function _is_code_or_meta()
* Update apply_fixes() to bubble illegal segments up the tree
* Fix a bug, add an assertion, add a log message when auto-fix fires
* Comments, tidying, replace loops with takewhile()
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Fix bug where L018 warns inappropriately if CTE definition includes a column list
* Simplify
* Add comment
* Fix crash in rules critical errors test
* Oops, last fix was bugged
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
* Fix bug where L003 and L036 fixes caused a parse error
* L036 fix, test case
* Simplify .sqlfluf test file
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Fix bug where the fix_even_unparsable setting was not being respected in .sqlfluff
* Add explanatory comment for the chdir()
* Add missing file
* PR review
* PR review: Fix capitalization of related code
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
* Fix issue where L025 was removing the alias for a FLATTEN() call
* Revisit L025: Was working correctly
* Add L027 test case
* L025: Don't warn or remove unused aliases for table functions
* Improve test case comment
* Alternate fix for issue 3178
* Fix broken tests
* Trigger build
* Coverage, tidying
* Remove unnecessary changes
* Update type hint
* Undo formatting changes
* Add a test case, improve test case comments
* Trigger build
* Add new test case per PR review
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
* Snowflake: Moved View to unreserved keywords
* Snowflake: Add Support For SQL Keyword
* Added SQL to procedure
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Update Violation printing
* Adedd back missing nocover
* Linting and coverage errors
* Remove Typeguard
* Ignore and force types on strange typing error
* Ignore and force types on strange typing error
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Bug fix: L028 sometimes makes incorrect fix when there are subqueries
* Move the "number of aliases" check out of _generate_fixes(), because it's about to be more complex
* Refactor: Convert _generate_fixes to a generator; this will make fixing easier
* Refactor to recurse over the entire "tree" of queries
* Fix the bug
* Fix the bug, tidying
* Tidying
* Fix crashes in critical rules errors test
* Fix another crash in rules critical errors test
* Fix crash
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
It was already in `merge`, but now `insert`, `update` and `delete` get
support, too.
Issue: 2698
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* L064: Consistent usage of preferred quotes for STRING datatype
* Fix CI a bit
* Cleanup code
* Don't put strings into lint error
* Format
* Increase coverage
* Remove unnecessary conditional
We added an additional statement to the if clause that handles cases where neither prefered or alternate quotes don't exist and exit early.
So removing part of the code that was copied from black but is unreachable in our implementation.
* Disable rule by default
* Cleanup comments and docs
* Add more test cases
* Add consistent configuration option
* Bring back raw and fixed string in lint error
In scenarios where the string contains a lot of quotes it might be very hard for the user to tell what is the "correct" way of quoting.
* Update src/sqlfluff/rules/L064.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Update src/sqlfluff/rules/L064.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Move constants into rule
* Update src/sqlfluff/core/rules/config_info.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Update src/sqlfluff/rules/L064.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Update src/sqlfluff/rules/L064.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Clarify tripple quote escape behaviour
* Make warning a bit less scary
* Update src/sqlfluff/core/default_config.cfg
* Update src/sqlfluff/core/default_config.cfg
* Update src/sqlfluff/core/rules/config_info.py
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Update src/sqlfluff/rules/L064.py
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Update src/sqlfluff/rules/L064.py
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Update src/sqlfluff/rules/L064.py
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Update src/sqlfluff/rules/L064.py
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Remove scary warning
* Remove config option
* Improve flags checking
* Add comment clarifying origin of normalization code
* Clarify raw string body handling
* Make regex helper function intend more clear
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Hive: Support dynamic partition insert
* Add testcase
* Merge multiple examples as one file
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Bugfix: StartsWith() in FromExpressionElementSegment caused massive performance issues in Snowflake
* Linting
* Reverting change made by wrong version of black
Extra WITH statements could be associated with the compound statement.
Fixed by replacing match_grammar StartsWith and parse_grammar optional
Sequnce with a match_grammar Sequence.
Co-authored-by: Jonathan Forrest <jforrest@eskatos.com>
* test cases for literals
* update for literals
* linting fixes
* updates tests
* add some no cover comments
* one more no cover comment
* final no cover comment
* revert L006.py
* revert L048.py
* update to sparksql and refresh yml files
* most recent changes
* add SignedQuotedLiteralSegment
* update yml
* remove no cover comments from L006
* formatting
* additional test cases for L048 and L006
* Apply suggestions from code review
* Update src/sqlfluff/rules/L006.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* TSQL: Exclude non-function-name keywords from function names
* TSQL: Exclude non-function-name keywords from function names
* TSQL: Exclude non-function-name keywords from function names
* TSQL: Exclude non-function-name keywords from function names
* TSQL: Exclude non-function-name keywords from function names
Co-authored-by: jpersons <jpersons@iuhealth.org>
* When fixing a file, preserve the input file's permissions
* Set mode before overwriting existing file
* Update command-line test to verify file mode is preserved
* Fix broken tests
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
* Fixes can't span template blocks
* Rename pre-existing block_idx variable to slice_idx to avoid name collision
* Add test
* Increment index *after* block_end tag, not before
* Fix some broken tests
* Compute fix slices differently
* Compute fix slices differently for this check
* Simplify the changes
* Fix more bugs
* Refactor how we decide which slices to consider
* Trigger build
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
* L010: Add `ignore_words_regex` configuration option
* Simplify attribute handling
* Add tests to L010
* Add `ignore_words_regex` to L029
* Add `ignore_words_regex` to L057
* Add `ignore_words_regex` to L059
* Apply black
* Fix yamllint
* Make sure all code is covered by tests
* Change to use `regex.search`
* Apply black
* Rework `ignore_words_regex` unquoted test
* Small improvement to L030 test
* Clarify usage in partial matches in `ignore_words_regex`
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
The suggestion is purely based on my assumption as to how the author
expected to phrase the sentence.
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Refactor rule segment iteration for flexibility and speed
* Fix a bug that was clearing memory when _eval() returned None
* Create CrawlBehavior class, fix broken test
* Update rule L009 to set recurse_into = False
* After first linter loop pass, skip rules that don't do fixes
* Reduce number of RuleContext objects, compute siblings_pre/post on demand
* Add "raw_segment_pre" as an alternative to "raw_stack"
* Coverage
* Rules declare whether they need context.raw_stack
* Implement linter phases so post-processing rules only run once
* Tidy, simplify
* Update L050 to use recurse_into = False
* Tidying
* Tune L003 a bit
* Refactor L003 for performance, add RuleContext.final_segment property
* Comments, coverage
* Refactor core rule processing for flexibility and speed
* Only "main" phase when linting (as opposed to fixing)
* Move test fixes from big PR
* PR review
* Simplify how we detect first linter pass and track lint violations
* Coverage
* Apply suggestions from code review
Comment changes suggested by Barry Pollard
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* PR review
* PR review
* Comments, tidying
* Update rule development docs with some of the new (and old) options
* Add more comments about needs_raw_stack
* PR review
* Apply suggestions from code review
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* external function added and alter function edited
* ran pre-commit
* last minute edits
* Update src/sqlfluff/dialects/dialect_snowflake.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Update src/sqlfluff/dialects/dialect_snowflake.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Update src/sqlfluff/dialects/dialect_snowflake.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Update src/sqlfluff/dialects/dialect_snowflake.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* fix errors
Co-authored-by: Chris Alexeev <chris.alexeev@trimedx.com>
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Refactor core rule processing for flexibility and speed
* Only "main" phase when linting (as opposed to fixing)
* Move test fixes from big PR
* PR review
* Simplify how we detect first linter pass and track lint violations
* Coverage
* Apply suggestions from code review
Comment changes suggested by Barry Pollard
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* PR review
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Add editorconfig and precommit for SQL and YML files
* Revert unintended change
* Fix test
* Fix another test
* Editorconfig update
* Fix another test
* More fixes
* Fix parse error for ALTER ROLE and ALTER USER statements.
* Missed a trailing comma.
* Update src/sqlfluff/dialects/dialect_postgres.py
Co-authored-by: Mark Ferree <mferree@varomoney.com>
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Update inthewild.rst
Add Carepay to SQLFluff in the wild
* Update docs/source/inthewild.rst
* Update docs/source/inthewild.rst
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Creating new segment to resolve parse error on CREATE USER calls.
* Adding class definition, keywords, more test cases
* Removing unnecessary whitespace change
* Combining CREATE USER and CREATE ROLE
* Fixing 'SuperuserKeywordSegment' which was not found in the redshift dialect
' errors
Co-authored-by: Mark Ferree <mferree@varomoney.com>
* commit to push for feedback
* update to use OneOf and exclude to pass tests
* create and update yml files
* black
* switch anynumberof to oneof in exclude argument
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Force user to specify a dialect
* Try to get tests working with no default dialect
* Trigger build
* Fix some of the broken tests
* Fix test/cli/commands_test.py
* Fix test/core/config_test.py
* Fix test/core/linter_test.py
* Fix test/core/parser/lexer_test.py
* Fix more tests
* Fix some tests
* All tests in test/core/ are working
* Add comment
* Linter() constructor shouldn't require a dialect
* Fix more tests
* Fix most YAML tests, also test/rules/std_test.py
* Fix broken example and rule
* Fix dbt tests
* Fix broken test, remove .sqlfluff to see what breaks
* Fix issue with benchmarks
* Fix simple command-line GitHub CI tests
* Fix diff-quality tests
* Fix more tests
* Fix some old issues with progress bar tests
* Add test/fixtures/.sqlfluff
* Tidying, add test to address coverage gap
* Don't require path initially for sqlfluff lint, parse, and fix commands
* Undo unnecessary change
* Update src/sqlfluff/core/config.py
* Prefer configs to override
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Fixes for CREATE ROLE and DROP ROLE (postgres)
* Update src/sqlfluff/dialects/dialect_ansi.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Update src/sqlfluff/dialects/dialect_ansi.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Update src/sqlfluff/dialects/dialect_ansi.py
* Update src/sqlfluff/dialects/dialect_ansi.py
* Review feedback
* Correct typo
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
Co-authored-by: Barry <barry@tunetheweb.com>
* Added support for CLUSTER BY function(), also relaxed ordering requirements for CREATE TABLE
* Black
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* T-SQL: add support for assignment operators
* Cleanup & add a type for class
* Add support for compount operators for Updates (fix#2008)
Co-authored-by: Paul Guyot <pguyot@upclear.com>
* Added support for MySQL Update Statements
* Added multi-table example
* Update src/sqlfluff/dialects/dialect_mysql.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Make UpdateStatementSegment consistent across dialects
* Linting fixes
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* TSQL grammar deduplication
* Rename Segments -> Grammars
* Statement terminators should be between statements not within them
* linting
Co-authored-by: Alan <alanmcruickshank@gmail.com>
* Calculate Tempalte info with Line using class
* _LineSummary for the win
* _Memory joins the team
* L003 preformance improvements
* Correct Comment Errors
* Coverage fixes
* linting errors
* memo is_empty
* Fix coverage
* linting Issue
* Seperate out more sub elements
* Hanging into method
* Running Again
* further clean up
* spelling Errors
* Comments spelling and fStrings
* Linting Bugs
* Fixed now incorrect tests
* remove unneeded test
* remove useless lcass method
* Compact rules
* be explicit
* Fix cli output test
* Fix typos
* denest functions and gitignore
* DAte no longer capital
* support for reading snapshots in delta
* fixed a missed Spark3 reference the in README
* change atsign_literal to at_sign_literal
* remove AsOfGrammar
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Fix assertion error in dbt templater when file ends with whitespace strip ("-%}")
* Fix the bug
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Fix: vars_from_cli
* Updated Dev container config
* fixed missing requirement to use buildkit
* parametrized .dbt/profiles.yml to point to correct container
automatically
* Update plugins/sqlfluff-templater-dbt/test/templater_test.py
* Update plugins/sqlfluff-templater-dbt/test/templater_test.py
* Black (again) - wish I'd never started this!
* Minor fixes
* Update templater_test.py
Copy DBT_FLUFF_CONFIG before modifying
* Update docs/source/configuration.rst
Co-authored-by: Tomasz Cholewik <tcholewik@consumer-edge.com>
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
Co-authored-by: Barry <barry@tunetheweb.com>
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Remove redefinition of data type segment.
* Redefine data type identifier.
* bring the ansi dialect into line
* Don't reserve timestamp in teradata
* default the other way
* revert change to teradata
* Do exclude keywords in datatypes
Co-authored-by: Barry <barry@tunetheweb.com>
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Add back runtime checks for "replace()" that were deleted in prior PR
* Clean up Snowflake dialect
* Fix inconsistent segment type names
* More tidying
* Postgres cleanup
* Clean up sparksql dialect
* Revert bad change
* Remove inheritance, fix segment type
* Add back blank line that was removed
* Regenerate YML files
* Require explicit override of both match_grammar/parse_grammar if parent has both
* Fix bug in PartitionClauseSegment
* Add type hints to ANSI dialect so others won't need "type: ignore"
* Fix typo
* More "type: ignore"
* Coverage
* Add error-check test as suggested in PR review
* Remove no covers
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* change dialect name spark3 to sparksql
* fix docs
* fix spark3 to sparksql in l026 comment
* fix spark3 t osparksql in L057 comments
* Update test case
Co-authored-by: Barry <barry@tunetheweb.com>
* Add Symend to the list of companies using SQLFluff in the wild
* Better english
* Update docs/source/inthewild.rst
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* To replace base dialect segment class, must subclass or provide same stuff
* Fix spark3 and redshift dialects
* Fix exasol dialect
* Fix oracle dialect
* Fix teradata dialect
* Add comments
* Add "no cover"
* Experimental changes to make dialect inheritance simpler, more type safe
* Fix bad reference
* Fix bad reference
* Use absolute module paths, not relative
* Eliminate need for "@segment" decorator
* Update spark3 and bigquery dialects
* Update remaining dialects
* Switch to static segment inheritance
* Remove unused function
* Improve docstring
* Call add_update_segments() automatically (from load_raw_dialect())
* Fix tsql
* Fix TSQL the right way
* Fix broken tests
* Use inheritance to simplify
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
* To replace base dialect segment class, must subclass or provide same stuff
* Fix spark3 and redshift dialects
* Fix exasol dialect
* Fix oracle dialect
* Fix teradata dialect
* Add comments
* Add "no cover"
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
* Add new rule L063 to allow separate capitalisation policy for Datatypes
* More fixes
* Add some extra guards
* Fix test
* Update src/sqlfluff/core/rules/base.py
* Added Support For Snowflake Inline Comments
* Added slashes to trim start
* Added classic inline comments to Snowflake Inline Comment File
* More in-liney commments
* L042 fix fails with AttributeError on non-ANSI dialects
* Remove broken code from test
* Second try at the fix (cleaner)
* Add similar test file to Postgres dialect test directory for "Critical rules test
* Add missing YML file
* Rename test file per PR review
* Rename again
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
* Fix AssertionError in dbt templater when file ends with multiple newlines
* Fix failing tests
* Add test
* Comments, tidying
* More comments
* Undo some cleanup changes that broke stuff
* Add back newlines that I accidentally removed
* More comments per PR review
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* dbt templater should gracefully skip macro files
* Add automated test to verify dbt macros are skipped
* Parametrize existing tests for disabled files to also test macro files
* Fix macro skipping for dbt < 1.0
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
* Disable L031 on BigQuery due to complex backtick / project name behavior
* PR review
* One note, not two
* Apply suggestions from code review
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Run Black
* Update src/sqlfluff/rules/L031.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Add doc decorator
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* show statements
* black
* fix l044 for alter view test case
* fix L044 for create table datasource test cases
* updates to and test cases for L014
* fix L014 tests to specify spark dialect
* current draft for feedback
* remove extra code
* fix and text cases for L057
* finalize test for L059
* fix for select_delimited_identifier_with_escaped_backticks test case
* refresh yml files and formatting
* Update src/sqlfluff/dialects/dialect_spark3.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Update src/sqlfluff/dialects/dialect_spark3.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Apply suggestions from code review
Co-authored-by: Lorin Dawson <22798188+R7L208@users.noreply.github.com>
* Regen YAMLs
* Run black
* Remove unused import
* More black
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
Co-authored-by: Barry <barry@tunetheweb.com>
* Minor cleanup/refactor of JinjaTracer
* More refactoring
* More refactoring
* More refactoring
* Add more type annotations
* Extract a function track_block_end() out of update_next_slice_indices()
* Make some functions static
* Split up _slice_template() some more
* More types and tidying
* RawSliceInfo: Provide default value for next_slice_indices
* Use RawSliceInfo instance instead of alt_id/alt_code variables
* Split JinjaTracer into two classes: JinjaAnalyzer and JinjaTracer
* Make idx a field, rename as idx_raw
* Tidying
* PR review
* PR review
* Add explanatory comment about str_buff and str_parts
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
* Semi Working Draft
* Fix the CTEs
* Clean up type checking
* Cover clashing test cases
* fixed all the things
* update for 3.7
* imporve cover
* cleanup linting errors
* Doc strings and linting
* merge conflicts
* fix linting issues
* Safely get dialect Segement defs
* corrcet mypy issues
* refactor based on comments
* return removed test
* MY not understanding generics
* Fixed Pending L032
* align with Main
* Added test for failing query
* Added test for failing query
* Force position/Apply inline replace
* create fresh point
* actually use template slice
* Update test/fixtures/linter/autofix/ansi/L042_subqueries_in_joins/after.sql
* Update test/fixtures/dialects/ansi/unaliased_using_subquery.sql
* Update test/fixtures/linter/autofix/ansi/L042_subqueries_in_joins/before.sql
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* L009: Handle adding newline after {% endif %} at end of file
* Lexer should add trailing placeholders if needed
* Fix L009 to run on the actual final segment, *even if meta*
* Update iter_patches() to return EnrichedFixPatch for better fix placement
* Fix broken test
* Comments, type hints
* First draft of refactor how we handle FixPatch vs EnrichedFixPatch
* Second phase of refactoring FixPatch
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
* Fix a design flaw in handling of Jinja "{% set %}" blocks
* Remove print() statement
* Comments
* Fix dbt test failures, move slice sanity checks
* Fix remaining broken tests
* Formatting tweaks
* Remove extra newline
* Fix old bug in test
* Add a test
* Skip consistency check for base templater tests
* Add comment
* Tweak comment and whitespace
* Fix issue 2835, add tests
* PR review: Add explanatory comment
* Add guard in case list is empty
* Fix broken test
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
* Semi Working Draft
* Fix the CTEs
* Clean up type checking
* Cover clashing test cases
* fixed all the things
* update for 3.7
* imporve cover
* cleanup linting errors
* Doc strings and linting
* Imporved testing
* fix linting issues
* Safely get dialect Segement defs
* corrcet mypy issues
* refactor based on comments
* return removed test
* MY not understanding generics
* Bug fix: "ValueError: Position Not Found for lint/parse/fix" in JinjaTracer
* Add test case for the bug
* DRY up the code, add commments, fix a test
* Remove .sql test case, add a similar but smaller test case to jinja_test.py
* Add generated YAML file
* Remove unneeded code
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
* In job `python-version-tests`, we already told the version we
setup in step `Set up Python`, so we could simply run command
`tox -e py` to trigger the job, so we could remove the
`Set Tox Python Param` step
* In job `other-tests` we just set unused vairable by one step
and I think we should directly remove it.
* support for reset statement
* DRAFT for set statement
* finalize SetStatementSegment
* remove missed segments in StatementSegment
* feedback from review
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Bash --> Pytest
* Remove test refs & add cache
* fix Doc str
* Imporve all the tests
* speed up tests maybe?
* removed over caching
* remove typo from test
* make it use Cores
* add more cores
* Remove Caching etc
* Cleanup imports
* Fix L052 bug deleting space after Snowflake SET statement
* Make a similar fix elsewhere in L052, DRY up the code
* Update tests to raise error on fixes with duplicate anchors
* Fix L036 bug: Deleting the same segment multiple times
* Rework the fixes to use object *identity*, not *equality*
* Comments
* Update L052 to use IdentitySet
* Coverage checker
* Update src/sqlfluff/core/linter/linter.py
* Update test/fixtures/rules/std_rule_cases/L052.yml
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* PR review: Raise log level for these messages to CRITICAL
* Add comment per code review
* Update test/fixtures/rules/std_rule_cases/L052.yml
* Bug fix to IdentitySet
* Update L039 to avoid returning multiple fixes with same anchors
* Add test case for fixed L039 issue
* Fix one of the post-fix parse error bugs in L053
* Fix L053 bug, allow create_before + create_after for same anchor
* Tweaks
* Fix type annotation
* Comments, tweaks
* Fix bug in L050, fix missing space in message
* Remove commented-out code
* Add "pragma: no cover"
* Add "pragma: no cover"
* PR review
* More L039 comments
* Discard fixes from lint results if tehre are conflicts
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Prevent iiteration error in get_select_statement_info
* Add some extra guards
* Better if
* Even better if
* Indentation
* Review feedback
* Add test cases
* Change test from lint to fix
* Add types
* Coverage
* Typo
* add support for auxiliary cache and uncache statements
* new test cases for fixing options grammar to allow more than just strings
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
* Post-fix parse check: Prefer parse_grammar over match_grammar
* Bug fix for _choose_anchor_segment()
* Add comments
* Apply suggestions from code review
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Simplify how we check (parse) the fixes
* Add test case that runs multiple rules
* Type hints, tidying
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Automated tests should fail if a lint fix introduces a parse error
* Use the right formatting function (actually operator)
* Some L052 fixes
* More L052 fixes
* Add "pragma: no cover"
* Include rule code (i.e. identifier) in parse error output
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
* Add openid support for create/alter user
* Add capitalisation + merge parse/match_grammar
* more capitalisation
* Update src/sqlfluff/dialects/dialect_exasol.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Postgres: Complete DELETE FROM grammar
* Add DELETE statement to WITH grammar
* Add WITH RECURSIVE example
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
* REDSHIFT: Add support for procedures
* cover some more cases + review definition of procedure parameter list
* @tunetheweb's comments:
- move CompressionType, ArgMode and ColumnEncoding to grammars instead of segments
- clean up StatementSegment to keep only statements
- renaming some classes for the sake of clarity
* Update src/sqlfluff/dialects/dialect_redshift.py
* Black
* Allow change in params
* Black
* Add max_times_per_element
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
Co-authored-by: Barry <barry@tunetheweb.com>
* support for analyze table
* adjust type on ListFileSegment and ListJarSegment
* change type of noscankeywordsegment
* Update src/sqlfluff/dialects/dialect_spark3.py
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* L007 autofix
* Fix small typing issues
* No cover unreachable code
* Fixed no cover and line lenght
* remove newlines that imply new test but arent
* changed to functional approach
* even shorter
* shortened code
* improved typing
* Fix typing issues
* syntax shortening
* no cover __iter__
* Update src/sqlfluff/core/rules/functional/segments.py
* Update src/sqlfluff/core/rules/functional/segments.py
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Fix USING -> ON when the join is implicit
* remove unneeded newlines
* Added newlines between tests
* linting fixes
* Update src/sqlfluff/core/parser/segments/base.py
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Update src/sqlfluff/rules/L032.py
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Embrace the Optional
* Remove useless Comment
* Update src/sqlfluff/rules/L032.py
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
* Fix dbt templater runtime error in inject_ctes_into_sql()
* Add back blank line that was accidentally removed
* Make it more efficient
* Update plugins/sqlfluff-templater-dbt/test/fixtures/dbt/dbt_project/models/ephemeral_3_level/stg_max_product_contract_seats.sql
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* L059: Allow quotes around passwords in CREATE USER
* Define a list of types to ignore
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Added first LIKE segment
* See if this fixes recursive references
* Added more segments
* Committing PatternMatchingExpressionSegment so far
* Added first LIKE segment
* See if this fixes recursive references
* Added more segments
* Committing PatternMatchingExpressionSegment so far
* Rolled back dev changes for the ANSI dialect
* Copied Expression_A_Grammar to postgres
* Added first LIKE segment
* See if this fixes recursive references
* Added more segments
* Committing PatternMatchingExpressionSegment so far
* Added first LIKE segment
* See if this fixes recursive references
* Added more segments
* Committing PatternMatchingExpressionSegment so far
* Rolled back dev changes for the ANSI dialect
* Copied Expression_A_Grammar to postgres
* Added Like operators
* Updated postgres dialect
* Updated implementation
* Implemented SIMILAR TO
* Added SIMILAR TO tests
* Added POSIX Expression and Operator
* Simplified implementation + added redshift tests
* Linted
* Added TODO
* Added links to issues addressing TODOs
* Simplified to LikeGrammar overwrite
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Deleted bloat not needed due to LikeGrammar overwrite
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Reverted LikeOperator changes in Postgres
* Deleted unnecessary TODO
* Updated yml hashes
* Linted
* Update src/sqlfluff/dialects/dialect_ansi.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Forgive CAST only / bracket only expressions from L013
* remove commented out test
* fixed YAML linting error
* remove dead code
* cleaned up comment spelliing errors
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
* L052: Move semicolon handling to a separate function
* Split semicolon handling into multiple functions
* Tidying
* More tidying, move "ensure semicolon" logic to a separate function
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
* Fix tests: assert that fix_str passes the rule
* Remove fix_str + add TODOs
* Remove fix_str + add TODOs
* Add help comments in assertions
* Add missing fix_str (fix succeeds)
* Roll back indent only changes
* Explain why L004.yml has failing fix_str's
* Try noqa for L003.yml (still fails)
* Enforce that fix_str passes or violations_after_fix is defined
* Drop outdated comments
* Update src/sqlfluff/testing/rules.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Update src/sqlfluff/testing/rules.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Update src/sqlfluff/testing/rules.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
* first pass at extending L051
* initial work on L051 extension
* clean up printing and add comments
* @tunetheweb's comments + switch from name to raw_upper for clarity
* add simple capitalisation to L051
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
* Support for checking violations in YAML rule tests
Adds a new optional feature for the YAML rule test cases (run with yaml_test_cases_test.py):
- `violations` or `violations_after_fix` can be defined in YAML to check for specific failures
Taking `violations_after_fix` into use for the tricky cases of L004. With that, the python test with the same coverage is deleted.
Also adding the `violations` assertion for one "fail_str only" case to demonstrate how that works.
* Default to test rule if code is omitted
* Format newlines in L004.yml
* Simplify assertion code
* Revert "Simplify assertion code"
This reverts commit d7137101d8f512da8cd7b074ca3fe439a7879813.
* Ignore missing coverage
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
* See if this fixes things
* Deleted allow gaps
* Update to segment
* Added test cases
* Reverse Redshift changes
* Allowed gaps for cast operators
* Added ansi and postgres whitespace coverage
* Linted
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
* Rule L019: Anchor on column, not comma, to reduce templating false positives
* Don't overwrite pre-existing "core" config
* Fix failing test by rolling back one of the changes, add comments
* Fix an issue where the new anchor segment was too "big"
* More comment
* Tweak the anchor for trailing comma violations
* Tweak again
* Fix broken test
* Rework the fix so we don't change the anchor
* Add more sophisticated template handling
* Simplify the fix
* Add back a pre-existing newline that was unnecessarily removed
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
* OptionallyBrackedWith
Support (WITH cte AS (...))
in particular this is used in:
```
INSERT INTO schema.table
(
WITH cte AS (...)
SELECT ...
)
* AddTestForNestedCTE
Test nested CTEs which although stupid are valid
* Linting line len
* trailing comma linting err
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
* Core linter enhancement: Check for successful parse after applying fixes
* Work around import error
* Refine the "reparse" logic
* L003 (indentation rule): Improve anchors for fixes to avoid corrupting parse tree
* Tweak docstring
* Work around the issue with calling parse() in apply_fixes()
* Use the correct dialect for re-parsing
* Fix how we detect and handle parse() errors after applying fixes
* Anchor placement based on start or end of slice, not the whole slice
* Move anchor adjustment logic into RuleBase, so other rules can reuse it
* Filter out meta segments when calling match()
* More tweaks to how we call parse() after fixes
* Fix a failed test
* Remove some obsolete template-related filter logic
* Update test case
* Remove some hacky logic added in this PR that's breaking things now
* Update test-only rule that was causing a parse error after fixing
* Fix anchor for inserting newline
* Fix an issue with the templated_file field on position markers
* Rework _choose_anchor_segment() to handle new segments created by "fix"
* Fix a bug in _choose_anchor_segment(): Stop before hitting tree root
* Fix some L036 issues causing test failures and/or failures on re-parse
* Fix newline placement
* Fix more test failures
* Fix two tests that were triggering post-fix parse errors
* Fix last post-fix L036 parse error
* Add deepcopy() before match()
* Remove obsolete tests (the corresponding code was obsolete, removed in this PR)
* Remove obsolete code (workaround for the bug we're fixing in this branch)
* L039 bug fix: Ignore meta segments
* Tidying
* DRY up L036
* More tidying L036
* More tidying L036
* More tidying L036
* Add docstring to _fixes_for_move_after_select_clause()
* Remove unused code
* Log warnings rather than throwing exception on re-parse error
* Coverage, missing spaces for parse error handling
* Fix crash bug found during manual testing
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
* allow named argument to accept an iterable
* updated to allow for LATERAL VIEW
* black
* use OneOf instead of list for exclude
* use get_segment to define get_eventual_alias
* remove unused imports
* PR feedback
* black
* Update src/sqlfluff/dialects/dialect_spark3.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* remove AnyNumberOf AliasExpressionSegments
* black
* remove two invalid test cases and update LateralViewClauseSegment
* refresh yml
* updates to LateralViewClauseSegment
* excldue spark3 from L026 by default
* black
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Pin python version for pre-commit hooks
Most notably this pins python version for the mypy pre-commit hook so that it's aligned
* Doc python req for tox, remove basepython
* Update CONTRIBUTING.md
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Update CONTRIBUTING.md
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
* Improve Exasol function formatting.
* revert unnecessary change
* Add formatting test cases to L003
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
* updated snowflake dialect to include predicates for merge statement not matched clause
* Update src/sqlfluff/dialects/dialect_snowflake.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Update test/fixtures/dialects/snowflake/snowflake_merge_into.sql
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* regenerated yaml after adding semi-colon for snowflake merge
Co-authored-by: seve martinez <seve.martinez@coinbase.com>
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Assert that fix_str is set
* Update src/sqlfluff/testing/rules.py
* Update src/sqlfluff/testing/rules.py
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Implemented DATETIME support as a datatype for Redshift
* Added more postgres examples around DATETIME
* Linted
* Rebased
* Added more postgres examples around DATETIME
* Linted
* Updated hashes after conflicts
Covers these type of mistakes:
- Successful fix, but fix_str missing to assert the result -> add the missing fix_str
- pass_str used instead of fix_str, ie. fix would not be asserted -> change pass_str to fix_str
- Unfixable failure, but fix_str is used with the same value as fail_str. Doesn't make sense to do that -> remove fix_str.
* Fix parsing types and add check to test in future
* Fix test case
* Regen yamls
* Pragma no cover
* Update src/sqlfluff/rules/L052.py
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Update src/sqlfluff/rules/L052.py
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Review feedback
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Migrate issue template from markdown to yaml
Change issue template to yaml make our issue form
more user friendly, and also make our issue structured.
It have some rule to make sure user have to fill
before they submit issue.
See more detail in
https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/configuring-issue-templates-for-your-repository#creating-issue-forms
* Disable blank issue created
* Improve documentation issue title
* Update .github/ISSUE_TEMPLATE/bug-report.yml
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Update .github/ISSUE_TEMPLATE/bug-report.yml
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Update .github/ISSUE_TEMPLATE/bug-report.yml
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Update .github/ISSUE_TEMPLATE/bug-report.yml
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Update .github/ISSUE_TEMPLATE/bug-report.yml
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Update .github/ISSUE_TEMPLATE/bug-report.yml
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Update .github/ISSUE_TEMPLATE/bug-report.yml
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Update .github/ISSUE_TEMPLATE/bug-report.yml
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Update .github/ISSUE_TEMPLATE/bug-report.yml
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Update .github/ISSUE_TEMPLATE/bug-report.yml
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Update .github/ISSUE_TEMPLATE/bug-report.yml
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Update .github/ISSUE_TEMPLATE/enhancement.yml
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Update .github/ISSUE_TEMPLATE/documentation.yml
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Update .github/ISSUE_TEMPLATE/enhancement.yml
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Change related content base on Barry suggestion
* Update .github/ISSUE_TEMPLATE/bug-report.yml
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Update .github/ISSUE_TEMPLATE/bug-report.yml
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Update .github/ISSUE_TEMPLATE/documentation.yml
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Update .github/ISSUE_TEMPLATE/enhancement.yml
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Update .github/ISSUE_TEMPLATE/bug-report.yml
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Update .github/ISSUE_TEMPLATE/documentation.yml
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Update .github/ISSUE_TEMPLATE/enhancement.yml
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Fix some format bug
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
Co-authored-by: Alan Cruickshank <alanmcruickshank@gmail.com>
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Bug fix: L025 should consider BigQuery QUALIFY clause
* Oops, need to specify dialect in test
* Rename test case
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
* L045 not reporting unused CTEs if the query uses templating
* Add test to check multiple results and dynamic lint message from L045
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
* L052: If require_final_semicolon is set, ensure semicolon after ALL statements
* Refining statement processing and semicolon detection
* Interim checkin, fixed several failed tests, but some still failing
* More attempted fixes
* Fix issue with moving semicolon -- need to delete the old one (NOW ALL EXISTING TESTS PASS!)
* Refactor: As statements end, save to a list rather than a scalar
* One of the new test cases is working; add them
* Update new test cases
* Tidying
* Fix crash, add test for the crash
* Update src/sqlfluff/rules/L052.py
* Simplify: Use create_after() rather than replace()
* More tidying
* Tidying
* Tidying
* Add "guards" to prevent IndexError
* Some bug fixes
* Tidying
* New test cases
* Tidying
* Fix critical errors in CI check. Breaks some tests, will sort this out later.
* Don't add semicolons after IF or BEGIN/END statements
* Fix final broken test
* Comment
* Move helper function
* Comments, tidying
* Fix crash seen in "Rules critical errors" test
* Move the "no cover" comment
* Add a "no semicolon" test per PR review
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
* L023 to also fix extra newlines in CTE
* Update expected cte query after fixing
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* update to SetOperatorSemgnet
* formatting
* Update src/sqlfluff/dialects/dialect_spark3.py
* remove exclude from SetOperatorSegment
formatting too
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Strict the order of fix compatible and config
This patch try to strict the order of rule's hand
writing docstring, fix_compatible, note, Configuration
and example pattern.
* Rule's hand writing docstring(expect example pattern
and note) is always in the fist place
* (Optional) Fix compatible in the second place
* (Optional) Note in the third place
* (Optional) Configuration in the fourth place
* Example pattern would always in the tail
* Fix flake8
* Fix rule 16 failing test
* Fix flake8
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Hitting the linter loop limit should cause an error
* Update the linter to handle loop limit issues correctly
* Add test case: We can use "noqa" to avoid the run failing with loop limit error
* Fix failing tests, improve comments
* Add back the "no cover" I had removed
* Revisit the loop limit change -- it was wrong to do this
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
* Fix QUOTED_IDENTIFER keyword issue in L059
* TSQL: fix bug in L059 for QUOTED_IDENTIFIERS keyword
* Apply suggestions from code review
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Allow Bare Functions in column constraints
* Update src/sqlfluff/dialects/dialect_ansi.py
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Support LIMIT and ORDER BY clauses in Values clauses
* Revert postgres changes
* Revert "Revert postgres changes"
This reverts commit d92a24d1127a761e5cdc2fa11ccc44124ad754d9.
* Fix Postgres
* L016: New option "ignore_comment_clause" to ignore column COMMENTs, etc.
* Fix it
* Self review
* Add test cases for dialect-specific comment_clause, etc.
* Apply suggestions from code review
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Add another test case per PR review
* Rename the rule config setting in the test YML file
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Bug fix: L016 ("Line is too long") should consider length of prior fixes
* Comments
* Add missing file
* Tweak for PR review
* More tweak
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
* initial work on mysql INSERT ON DUPLICATE KEY
* clean up dialect & yml tests
* Add terminator clauses to allow items to parse
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
* MySQL: UNIQUE KEY in CREATE TABLE
* Make UNIQUE KEY mysql specific
* Update src/sqlfluff/dialects/dialect_ansi.py
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
Co-authored-by: Barry <barry@tunetheweb.com>
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Bug fix: L003 should fix indentation for templated code
* Experiment
* Revert some experimental changes
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
* Look for .sqlfluffignore in current directory
* Add test for the fix
* mypy
* Try to fix Windows test failure
* Update last fix
* Possible fix: Use .absolute() rather than .resolve()
* Remove debug code, causing tests to fail
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
* Implemented fix
* Updated documentation + added first test case
* Added test cases in more detail
* Documented existing bugs from Issue #1672 .
* Linted
* linted
* Removed unnecessary optional
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Deleted test documenting existing bugs
Bugs will be addressed in Issue #2567 .
* Removed import
* Commit to support mypy tests
* Fixed formatting to pass mypy tests
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Capitalization rules (L010, L014, L030, L040) should ignore templated code
* Add L010 test case per PR review
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
* Simple API: Fix bug where omitted parameters still override .sqlfluff
* Create a fixture directory for the .sqlfluff file
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
* Add direct file query
reorganized file grammar to isolate file formats that allow this
removed xml file format for now since requires additonal work
* black
* fix segment decorator and add segment
* move FileReferenceSegment before TableReferenceSegment
this ensures a match on file reference and files are not matched as tables
* sqlfluff fix test file and update yml
* update docstring and add link to docs
* switch QuotedIdentifierSegment to QuotedLiteralSegment inside FileReferenceSegment
ran sqlfluff fix on tests and updated yml again
* additional test cases for L057 exception
* minor formatting
* add semicolons at end of new tests
* noqa for line to long on html link
* revert back to QuotedIdentifierSegment and add NB
* sqlfluff fix test cases
* add exceptions for identifiers to LO57
* refresh yml
* black
* return None for identifiers in FileReferenceSegment
* cleanup L057
* black
* remove redundant test case
* new test cases for L057
* update generated yml
* remove noqa
* Update src/sqlfluff/dialects/dialect_spark3.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* jinja and dbt templaters: More robust handling of whitespace control
* For blocks, remove whitespace control
* Improve docstring
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
* Improve how "sqlfluff fix" handles parse errors
* Don't fix if there are parse errors. Exit w/error if there are unsuppressed parse errors.
* First working version?
* Add test for "fix unparsable", update "fixing stdin" to use same logic
* Add a config option for fix_even_unparsable
* Update simple API with same fixing behavior
* Update docs
* Tweaks to handle parse errors correctly with multiple files
* Add a multi-file test
* Tweak wording in docs
* Remove blank line
* Tidying
* Tidying, coverage
* Update docs/source/production.rst
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Update src/sqlfluff/api/simple.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Update src/sqlfluff/core/default_config.cfg
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* PR review
* PR review
* Handle templating errors the same as parse errors
* Tidying
* PR review; fix after refactoring
* PR review
* Fix failing test, also update wording for "--ignore"
* Tweaks
* Add more detailed help for "--fix-even-unparsable", relating it to "--ignore"
* Command-line help tweak
* Tweaks
* Comments, readability
* PR review
* Update src/sqlfluff/cli/commands.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Update src/sqlfluff/cli/commands.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Update src/sqlfluff/cli/commands.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* PR review
* PR review
* PR review
* PR review
* PR review: Make the code clearer
* PR review
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* jinja and dbt templater: Fix "list index out of range" error
* Improve comments
* Update src/sqlfluff/core/templaters/slicers/tracer.py
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Correct parsing for BigQuery `SELECT REPLACE` clauses.
Fixes https://github.com/sqlfluff/sqlfluff/issues/2549
BQ's `SELECT REPLACE` requires parentheses around replaced fields, but
the BQ dialect implementation was permittig an invalid version without
it.
This implemetation had the side effect of also failing to parse a
`SELECT REPLACE()` with trailing comma and no additional fields, e.g the
following would not parse correctly.
```sql
SELECT * REPLACE(foo AS bar),
FROM foo
```
Removing the unparenthesised version from the dialect makes the parsing
more consistent with what BQ actually accepts, requiring the
parentheses, and resolves the parse error on the trailing comma.
* fixup! Correct parsing for BigQuery `SELECT REPLACE` clauses.
* Draft: #2527 Extend L059
Extend L059 to allow user-defined configuration to set if the identifiers must be always quoted or preferably unquoted, and when quotes are necessary or wanted, which one to use.
* Add new default config for L059
* New configs for L059
Add new configurations for L059
* Manage user-defined configuration for L059
Manage user-defined configuration to allow to force quoted identifiers, and prefer some quotes over others.
See #2527
* Add unit test for new cases of config management
* Update src/sqlfluff/core/rules/config_info.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Update src/sqlfluff/core/rules/config_info.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Update src/sqlfluff/rules/L059.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Update src/sqlfluff/rules/L059.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Add bigquery common use case
See https://github.com/sqlfluff/sqlfluff/pull/2537#discussion_r796575494
* Update L059.py
* Update L059.py
* Fix pylint
* Fixed some pylint errors
* Fix mypy error
* Provide single configuration for L059
Remove attempt to manage the type of quote to be used for quoted_identifiers.
* Remove `preferred_quote_identifier`
* Remove `preferred_quote_identifier` for L059
* Update unit tests of L059
* Update L059 documentation
* Remove trailing whitespaces
* Fix unit tests for L059
Fix tests as default dialect is ansi and backticks are not parsed. Added bigquery dialect tests to ensure this is working also with backticks when dialect is supporting them.
* Attempt to make black happy
* Run black
* Update src/sqlfluff/rules/L059.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Update src/sqlfluff/rules/L059.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Update src/sqlfluff/rules/L059.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Update src/sqlfluff/rules/L059.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Update src/sqlfluff/rules/L059.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Update src/sqlfluff/rules/L059.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Update src/sqlfluff/core/default_config.cfg
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Change test cases names due to configuration name change.
* Update src/sqlfluff/core/rules/config_info.py
* Update test/fixtures/rules/std_rule_cases/L059.yml
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
Co-authored-by: Barry <barry@tunetheweb.com>
* Adds nw rule to allow blocking of certain words
* Tidy up
* Fix linting failures
* Review feedback
* Docs
* Comments
* Comment
* more comments
* Review feedback
* Review feedback and new test
* Coverage
* More word crafting
* Unpin Black
* Run Black on two failing files, update Black version for pre-commit
* Drop support for versions of dbt prior to 1.0
* More dbt version stuff
* Remove more dbt version stuff from the dbt templater tests
* Run code coverage after 7 runs, now that 4 older dbt version builds were removed
* Add back some code I removed, causes test to break
* dbt templater: Fix bug where profile wasn't found if DBT_PROFILES_DIR contained uppercase letters
* Add comment
* Add an automated test for the fix
* DRY up the tests
* Add back support for dbt 0.20 and 0.21
* Update code coverage "# builds" setting
* Add back comment that was removed
* Remove redundant import
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
* dbt templater: Fix bug where profile wasn't found if DBT_PROFILES_DIR contained uppercase letters
* Add comment
* Add an automated test for the fix
* DRY up the tests
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
* Examples of VALUES failing to parse
* Additional example
* Try VALUES before functions in TableExpressionSegment
* show that VALUES clauses themselves all parse
* even simpler multi-value test
* yamls
* even simpler test queries
* even simpler test queries
* type annotations
* even more tests around values
* very explicit grammar tests
* fragments don't work in fixtured tests
* show that it matches lexed segments as well
* works with the values clause bracketed
* also one column cases can fail
* refresh yamls, consolidate working cases to one fixture to see where we are
* refine the grammar test a bit
* Slight cleanup of the new grammar pieces
* consolidate to working test cases
* Update src/sqlfluff/dialects/dialect_spark3.py
Typo spotted in review.
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Update test/dialects/spark3_grammar_test.py
bad copy-pasta caught in review
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* small comments
* clean up test
* a few more xfails
* black
* no expectation that select from values works in ansi
* Update src/sqlfluff/dialects/dialect_spark3.py
unnecessary `Ref` per reviewer
Co-authored-by: Joseph Young <80432516+jpy-git@users.noreply.github.com>
* Update src/sqlfluff/dialects/dialect_spark3.py
`Ref` for safety per reviewer
Co-authored-by: Joseph Young <80432516+jpy-git@users.noreply.github.com>
* couple more examples
* extra parens ok
* and the yaml
* reference issue with Delimited
* flake8
* Update src/sqlfluff/dialects/dialect_spark3.py
explicit choice between table and table column aliases, per reviewer
Co-authored-by: Joseph Young <80432516+jpy-git@users.noreply.github.com>
* Update src/sqlfluff/dialects/dialect_spark3.py
unnecessary ref
Co-authored-by: Joseph Young <80432516+jpy-git@users.noreply.github.com>
* quoted literal not allowed
* revert changes per reviewer's request
* TableExpressionSegment fixed upstream in https://github.com/sqlfluff/sqlfluff/pull/2404
* Note issues tied to xfails
* Tests from https://github.com/sqlfluff/sqlfluff/pull/2400/files for spark3, per suggestion: https://github.com/sqlfluff/sqlfluff/pull/2245#issuecomment-1018533160
* fixture yamls
* update comments
* errant blank comments
* recast xfails as commented TODOs
* remove tests in python per reviewer's request
* parse_grammar not needed here
* clarify that single quoted identifiers are not a thing in spark
* Update src/sqlfluff/dialects/dialect_spark3.py
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
Co-authored-by: Joseph Young <80432516+jpy-git@users.noreply.github.com>
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* TSQL: Add indentation for SET statement
* TSQL: Add indentation for SET statement
* TSQL: Add indentation for SET statement
* TSQL: Add indentation for SET statement
* TSQL: Add indentation for SET statement
* TSQL: Add indentation for SET statement
Co-authored-by: jpersons <jpersons@iuhealth.org>
* Added DO example
* Added DO example
* Added Draft of DO statement
* Tested happy path postgres_do case
* Added additional test case
* Refactored CREATE FUNCTION segment
* Added more postgres_do test cases
* Added fixtures with new language clause
* Refactored the lang clauses into the match_grammar
* Flaked the code
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* group by test cases
* code updates for group by clauses
* additional test cases
* formatting
* simplify WithCubeRollupClauseSegment
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Refactor date part functions
* Clean up
* More cleanup
* Apply suggestions from code review
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* More tweaks
* Try freezing Black
* Freeze Black pt2
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* "noqa" should allow ignoring template (TMP) errors
* Add source_str field to ParsedString
* Extra "noqa" comments from unparsed source string
* Filter template and parsing violations
* Tidying
* Report Jinja templater failures as "line 1"
* Tidying, add another test
* Doc string, comments
* Skip use of black 22.1
* Black version
* Black version, again
* Back to previous Black attack
* Another try with Black
* No cover
* Undo Black version workaround: that's moved to a separate PR
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
* Freeze Black due to incompatibility between 22.1 and flake8-black
* Fix typo
* Set minimum flake8-black instead
* Changes needed for Black 22.1.0
* Revert "Changes needed for Black 22.1.0"
This reverts commit 34e499714f23a0514c7caf168110c00874a01be1.
* Revert "Set minimum flake8-black instead"
This reverts commit c7795b144ab4887b348b4c52cc89166c2f24087e.
* Different approach
* Comments
* Add dbt_artifacts package to in the wild docs
* Update inthewild.rst
* Update docs/source/inthewild.rst
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
* dbt templater: For performance reasons, cache the database connection across models
* Add back the "set_relations_cache()" call: may be needed for performance
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
In T-SQL, function definitions must have parentheses, even if they have
no parameters.
On the other hand, procedures can have parentheses around parameters,
but they don't need to.
To correctly lint this difference, they now use different segments.
Issue: #2472
* Add linting of fixtures SQL for critical rules errors
* Revert tsql change committed in error
* Refactor to avoid having to rerun
* Break test to see how long it takes to run in full
* Change to run locally and error on failure
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Handle SELECT statements with no identifiers
* Fix typo
* Fix typo
* Correct Literal to Identifier
* More test cases
* Add no cover
* Freeze coverage in case that is the reason for our CI errors
* Correctly freeze coverage version
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* L003: Revisit recent change to improve speed
* Simplify
* Restore the "no cover" I removed
* Improve comment
* Undo L054 change; that's being moved to a separate PR
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
* Fix various rule exceptions
* Tidy up dateparts
* Fix rule L044
* Tidy up
* Revert non-date changes
* Revert change that wasn't supposed to be in this PR
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* L003: Ignore indentation of lines that only exist in templated space
* Update expected test results
* Fix the fix
* Coverage (not sure why?)
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
* Prepare version 0.9.2
* Fix date
* Remove need to separate into Bugs/Enhancements
* Add extra merged PRs
* Highlight new rule
* Include latest changes
* Update changes
* Apply suggestions from code review
Co-authored-by: Christoph Wiese <chwiese@users.noreply.github.com>
* Add latest changes
* Update text
* Add latest merges
Co-authored-by: Christoph Wiese <chwiese@users.noreply.github.com>
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Add Postgres DROP PROCEDURE support
* typos & clean-up
* add a test statement with two types of commas
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
* "sqlfluff fix" should exit with error if any parse errors found
* PR review
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
* Fix_Snowflake_CREATE_EXTERNAL_TABLE_statement
* Replace AnyNumberOf with AnySetOf in Snowflake dialect and remove redundant CreateStatementCommentSegment
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
* New rule L061 to use != over <>
* Make flake happy
* Respect tsql syntax and better CodeSegment replacement
* Quote "not equal to"
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Remove line break
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Apply suggestions from code review
- Line break
- Better description why we do that
- better readability for if statement
- More test cases
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
Co-authored-by: Joseph Young <80432516+jpy-git@users.noreply.github.com>
* Fix trailing whitespace
* Update src/sqlfluff/rules/L061.py
* Apply suggestions from code review
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
Co-authored-by: Joseph Young <80432516+jpy-git@users.noreply.github.com>
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
* MySQL: Values statement
* Allow ExpressionSegment
* Fix unit test
* Verify that using expression also fixes postgres cast in values
* Correct VALUES parsing
* L044, L045: Handle Exasol VALUES clause
* Add docs link
* Update/add test cases per code review
* Add postgres test cases
* Update test/fixtures/rules/std_rule_cases/L044.yml
Co-authored-by: Joseph Young <80432516+jpy-git@users.noreply.github.com>
* Update test/fixtures/rules/std_rule_cases/L045.yml
Co-authored-by: Joseph Young <80432516+jpy-git@users.noreply.github.com>
* Handle VALUES clause as the source of a top-level query
* Update comments in light of values_clause support
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
Co-authored-by: Joseph Young <80432516+jpy-git@users.noreply.github.com>
* Allow "load_macros_from_path" to be a comma-separated list of paths
* Fix broken test
* Coverage
* Revisit / improve Jinja macro docs
* PR review
* Add missing file
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
* insert overwrite directory code and test cases
* black
* Update src/sqlfluff/dialects/dialect_spark3.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
* Fix "connection already closed" issue with dbt_utils
* Update dbt_utils test case to test this issue as well
* Tidying, fix test
* Remove newline in test case
* Fussing with newlines in the expected test results
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
* initial commit for draft PR
* add yml file
* initial implementation for insert into
* update test files
add overwrite test cases
rename file to better reflect usage
* update docstring
* deleted unused yml file
* update test cases to remove todo and prevously unparsable code
* Rename InsertTableStatement
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Remove reference of InsertTableStatement
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* re-add insertTableSegment from ansi
* sqlfluff fix/lint on test file
* remove second TableReference & TODOs
Co-authored-by: Joseph Young <80432516+jpy-git@users.noreply.github.com>
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
* TSQL: Add ASA Clustered Index functionality
* TSQL: Add ASA Clustered Index functionality
* TSQL: Add ASA Clustered Columnstore Index order functionality
Co-authored-by: jpersons <jpersons@iuhealth.org>
Co-authored-by: Joseph Young <80432516+jpy-git@users.noreply.github.com>
* Add support for Jinja import and include
* Fix broken tests now that classmethod -> regular method
* Add support for "{% include ... %}"
* Fix broken dbt test(s)
* Add tests
* Test including from a subdirectory, move the test cases to a better place
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
* Exclude EMIT statements from L013
* Regenerate YMLs
* DocString
* Typo
* Add S
* More Ss
* More typos
* Review feedback
* Regen YMLs
Co-authored-by: Joseph Young <80432516+jpy-git@users.noreply.github.com>
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* L026: Handle DML statements and multiple levels of nesting
* Handle UPDATE statements
* L025 tidying
* Handle DELETE statements
* Add failure cases
* Tidying. Fix incorrect test case.
* Add "# pragma: no cover"
* Handle multi-part references (schema+table)
* Create a matches() function to separate reference resolution from the rule
* Refactor the reference matching function to use tuples, not strings
* Handle short references that match a *suffix* of the target
* Comments
* PR review: Handle the reverse case in the "suffix check"
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
* L043: Remove redundant CASE statement replacing NULLS with NULLS
* Handle interaction with L035
* Autofix test for L035 and L043 interaction
* fix comment
* Conf doc: add rule conf section
* Fix D001 Line too long
* README: Fix doc build command
* Update docs/source/configuration.rst
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Clarify cfg format vs. toml
* Add Enabling and Disabling Rules
* Oops, another doclint error
* Fixes according to review comments
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Features:
* Redshift data type
* Fix tests due to above feature
* Redshift CREATE MODEL statement
* Redshift SHOW MODEL statement
* DataTypeSegment comment
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
* Full REFERENCES grammar for CREATE TABLE statement
* Whoops missed a comma
* Add AnySetOf grammar
* Add AnySetOf to __init__.py files
* Add extra test
* Simplify conditions
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Snowflake: Flush out `ALTER TABLE`'s `tableColumnAction` grammar
* Flushed out `tableColumnAction` a bit more.
* Reorganized `snowflake_alter_table_column` test cases, so it's ordered
in the same way as the code.
* Update src/sqlfluff/dialects/dialect_snowflake.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Fixed linting
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
Co-authored-by: Joseph Young <80432516+jpy-git@users.noreply.github.com>
* Fix issue Linting throws "IndexError: list index out of range" on a valid syntax, snowflake 0.9.1 #2301
* Add quotes for pip install CICD test
* Switch to sha hash in pip install CICD action
* Switch pip install cicd test to local installation
* Remove --use-feature=in-tree-build to remove depracation warning
Co-authored-by: Joseph Young <80432516+jpy-git@users.noreply.github.com>
* L003 should consider only *literal* leading whitespace (ignore templated)
* Refactor and bug fix
* Linter
* Remove "targets_templated = True"
* Refactor, creating a reusable function, sp.raw_slice()
* Handle the "empty slice" case
* Add fail/fix test cases
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
Co-authored-by: Joseph Young <80432516+jpy-git@users.noreply.github.com>
* add COPY and UNLOAD statements in redshift dialect
* remove comments used for dev purposes
* barrywhart's comment on naming
* segment description update
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* L052: Fix case where no preceding segments and mulitline
* Update src/sqlfluff/rules/L052.py
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
* L009: Handle adding newline after trailing templated code
* Get it working
* Tidying, add two new modules
* Tidying
* Tidying
* Coverage
* Comments
* Add "pragma: no cover"
* Additional test suggested in PR review
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
* Update L009 to operate in raw, not templated space
* More robust
* Revert "More robust"
This reverts commit 8d364ec246419cf9c8a3d0bf338e22663e663928.
* Add test case
* More comments
* Coverage
* Change test to use a quoted string, to clarify what we're doing
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
* refresh statement implementation and tests
* refresh table and test cases
* refresh function implementation and test cases
* minor typo fixes
* update test fixtures
Co-authored-by: Joseph Young <80432516+jpy-git@users.noreply.github.com>
* code and tests for use database statement
* black formatting
* update test fixtures
* fix docstring of UseDatabaseStatementSegment
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
Co-authored-by: Joseph Young <80432516+jpy-git@users.noreply.github.com>
* Allow hyphens in L057 in quoted identifiers
* Make additional config configurable
* Add unquoted identifiers
* Refactor to avoid duplicating code
* Rename new variable
* Update description
* Spaces
* Split line to reduce with
* Refactor again to avoid need of separate function
* L025 should look at subqueries
* Fix broken tests
* Add tests based on the issue comments
* Fix broken test
* Update docstring
* Add another test case from the issue
* Readability
* Add comment
* Remove "note to self" comment noted in PR review
* Trigger build
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
* repair syntax for hive that spark depends upon
* unit tests for msck repair in spark
* repair table spark syntax
* refresh test fixtures
* black formatting
* update docstring for MsckRepairTableStatement
* additional clarification in MsckRepairTableStatement in spark3
making exlicit why it inherits from Hive
* update docstring for MsckRepairTableStatementSegment in spark3
additional clarity added
* add MsckTableStatementSegment to Hive
* update test files to reflect dialect changes
* update test fixtures
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Add Dedent to Snowfalke CREATE and ALTER STAGE
* Simplify Snowflake RegexParser expressions
* Fix Snowflake stage paths and COPY INTO statement
* Remove \n from Snowflake stage path lexer
* Rename ValidationModeSettingSegment
* Correct ValidationModeOptionSegment name and type
* Update copy into table yml test fixture
* Remove \n from Snowflake StagePath
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* initial attempt
* Alter postgres user password
* Move password earlier
* Try including db tests
* Tidy up
* Remove unnecessary pytest marks
* Update .github/workflows/ci-tests.yml
* Fix connection issue in dbt 1.0.0
* Set tests to use default Postgres database
* Add postgres service to GH action ci tests
* Fix test__templater_dbt_handle_database_connection_failure
* Fixing
* Correct database connection test
* Add real incremental model to test database connection
* Use mock to simulate database failure in "test__templater_dbt_handle_database_connection_failure"
* Attempt to ignore templator tests for Windows
* Move more tests
* Linting fixes
* Revert "Linting fixes"
This reverts commit 68b1bfb24aacfe4b82fa3b893833108b7e542454.
* Revert "Move more tests"
This reverts commit 2a5e662fa5190cf6f2ce4bcc21889ca6a58d56a2.
* Revert "Attempt to ignore templator tests for Windows"
This reverts commit ca71069685b69aca6b926590d73bf738814852d3.
* Attempt 2 to skip the tests for windows
* Linting
* Skip test on dbt versions below 1.0
* CONTRIBUTING.md: Document the dbt Docker Compose environment
* jy_cleanup (#2257)
* jy_cleanup
* Remove unnecessary dbt_connection mark
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
Co-authored-by: Barry <barry@tunetheweb.com>
Co-authored-by: Joseph Young <80432516+jpy-git@users.noreply.github.com>
* Docker Compose environment for SQLFluff developers
* Move all the files to plugins/sqlfluff-templater-dbt/docker/
* Fix some omissions with the Docker Compose Postgres configuration
* Remove commented-out code
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
* new unit test cases
additional cases for create_database a
nd create_function
new files with test cases for drop ddl syntax
* move drop database segment to ansi dialect
* refresh text fixtures
* refresh test fixtures
* temporary grammar for drop function
* replace DropStatementSegment in spark3
tsql doesn't allow temp|temporary keyword
* fix conflict b/w ansi and postgres dialect for drop function
* remove tempgrammar from dropstatementsegment
* additional comments for clarification
* fix type and update test fixtures
* fix linting errors
* refresh yml fixture for create database tests
* add DropBehaviorGrammar
* add DropBehaviorGrammar to dialects
* add DropViewStatementSegment
* add DropViewStatementSegment
* remove dropstatementsegment from ansi
* update exasol due to removal of dropstatementsegment from ansi
* update hive based on removal of dropstatementsegment from ansi
* update tsql due to removal of dropstatementsegment in ansi
* update sparksql for removal of dropstatementsegment in ansi
* remove commented out code from ansi
* add DropFunctionStatementSegment to sparksql
* add DropRoutineStatementSegment for procedures and functions
* black and flake8
* update for python snowflake test
* comment and minor syntax updates
* break out DropCascadeStatementSegment
broken into DropRoleStatementSegment and DropUserStatementSegment
* break out DropCascadeRestrictStatementSegment
broken into DropViewStatementSegment and DropFunctionStatementSegment
* minor changes
* split out DropRoutineStatementSegment
created DropProcedureStatementSegment and DropFunctionStatementSegment
* minor fix
* minor fix
* Update src/sqlfluff/dialects/dialect_exasol.py
* Finalise drop tweaks
Co-authored-by: Joseph Young <80432516+jpy-git@users.noreply.github.com>
Co-authored-by: jpy-git <josephyoung.jpy@gmail.com>
* Remove potentially unnecessary code dealing with Jinja "set" command
* Fix the bug, add a test
* Replace UUIDs with a counter
* Tweaks
* Simplify loop
* Tidying, also fix missing coverage
* PR review: Add explanatory comment to test
* PR review: Remove references to UUIDs
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
* Add numeric datatypes
* Removing double precision for a pipeline check
* Use a sequence for double precision
* Use uppercase
* Add unreserved keywords and lint the code
* Trying to change the parse tree
* Fix Redshift
* Update src/sqlfluff/dialects/dialect_postgres.py
Co-authored-by: Joseph Young <80432516+jpy-git@users.noreply.github.com>
* Remove obsolete file
* Clean Redshift dialect
* Regenerate fixtures
* Pre-Commit hook executed
* Add money datatype
* Add character types
* Remove precision from float4/float8
* Add binary type
* Add test for bytea
* Generate fixture
* Fix date/time types
* Generate fixtures
* Add boolean data types
* Add geometric types
* Add bit string types
* Add text search types
* Generate test fixtures
* Add UUID
* Add XML type
* Add Json types
* Add array types
* Add range types
* Add pg_lsn type
* Fix array
* Add int datatype
* Fix int issue
* Add user defined data types
* Add schema. to data types
* Fix templater jinja
* Use data_type_identifier as it is the ANSI dialect
* Fix hash after merge
Co-authored-by: Joseph Young <80432516+jpy-git@users.noreply.github.com>
* Fix several small issues with rule docs
* Fix keyword formatting
* More doc fixes
* Fix broken test
* PR review
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
* Don't allow fixes to copy code from templated regions
* Update LintFix factory methods, L031
* Implement the core check, add a test for L031
* Add comment to the test
* Fix rule 43
* Rule 58
* Update src/sqlfluff/core/rules/base.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
Co-authored-by: Joseph Young <80432516+jpy-git@users.noreply.github.com>
* Adding L058 rule
* Adding changes to default_config.cfg
* Updating L058 docstring
* Adding initial battery of tests
* Removing redundant comments from tests
* Adding fix to tests
* Fixing test cases to use the right rule
* Modifying rule number
* Modifying rule number
* Modifying rule number
* Adding default config for L059
* Adding capitalization test to L010
* Removing unnecessary bracket
* Fixing tests
* Removing redundant test
* Update src/sqlfluff/rules/L059.py
Co-authored-by: Joseph Young <80432516+jpy-git@users.noreply.github.com>
* Update test/fixtures/rules/std_rule_cases/L010.yml
Co-authored-by: Joseph Young <80432516+jpy-git@users.noreply.github.com>
Co-authored-by: Joseph Young <80432516+jpy-git@users.noreply.github.com>
* Update BaseRule.discard_unsafe_fixes() to avoid touching templated code
* Add test for the fix
* Fix some of the broken tests
* Fix the broken tests (but, break the new one!)
* Refine the algorithm: Start with templated slices
* Bug fix: Use the right TemplatedFile functions
* Fix failing test
* Fix more broken tests
* Undo unneeded changes
* Markdown wants a blank line here
* Remove incorrect comment
* Add "pragma: no cover"
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
* Create surrogate classes to simplify rule creation
* Expose surrogates from RuleContext
* Try to fix runtime error occurring in typing.py in Python 3.6
* Make coverage checker happy
* Coverage-related tweaks
* Change how segment attributes are accessed
* Refactor to fix circular dependency
* PR review
* Add common_predicates module with is_meta and is_expandable
* Tweaks
* Convert L021, change Segments to inherit from tuple, add more stuff to Segments
* Remove LintResult and LintFix stuff from Segments
* Move LintResult and LintFix back to base.py
* Rewrite rule L017
* Add Segments.first() and last()
* Rewrite L038
* Rewrite L013
* Undo accidental whitespace removal
* Add "reversed()" method, add some comments
* Change "first()" and "last()" to return a "Segments" instead
* Update L009 to use new surrogates API
* Inherit from list, not tuple. Fix a couple of issues.
* Fix some typing and linter issues
* Try and fix import issue in Python 3.6
* Remove support for Python 3.6
* Remove more references to Python 3.6
* Undo some changes that may be causing weird test failures
* Use relative import for segment_predicates to try and work around Python 3.6 issue
* Revert "Use relative import for segment_predicates to try and work around Python 3.6 issue"
This reverts commit 44cbe3babe3d5f852b6c820d6fe895860c33d085.
* Rename "surrogates" directory as "functional"
* Add "and", "or", and "not" functions, update L009
* Add unit tests for "segments" module
* Add unit tests for "raw_file_slices" module
* Disallow passing strings or classes as Predicates, now they must be functions
* Eliminate "Predicate" alias, use shorter import name for segpred, etc.
* Remove unneeded code
* Simplify code
* Add is_name predicate
* Add get_name predicate
* Fix L009 predicate implementation
* Convert all predicates to closures (for consistency)
* Rename Surrogates as FunctionalRuleContext, add missing properties
* Convert get_type() and get_name() to use closures, change select() parameters to functions, not lists
* Convert L001
* Update L008, add raw_segments property, all segments.py functions take single predicate
* Bug fixes
* Eliminate a temp variable
* Address missing coverage
* Remove "# pragma: no cover" from functions that may need tests
* Update rule development docs to mention the functional API
* Add a test for sp.and_()
* PR review
* Revert "Inherit from list, not tuple. Fix a couple of issues."
This reverts commit 443927cb66fb92d2ac46e9d0cdecf4d514b89bfd.
* Fix a bad import after the revert
* Convert L015
* Change "templated_file" to a keyword-only argument (for convenience of using the classes directly)
* Update L025, fix a test broken by the RawFileSlices API change
* Update test after Segments.__init__() API change
* Update L031
* Tweak L031
* Update L035
* Update L036, add Segments find() and get() functions
* More L036
* More L036
* More L036
* Update L041 to use awesome-pattern-matching
* More L041
* Rules docs
* Fix broken test
* Fix broken test
* Add "pragma: no cover"
* Update L042
* More L042
* Update L043
* Update L047
* Update L049
* More L049
* Clean up type hints
* Update L052
* Bug fix
* Tidying
* Trigger build
* More L017
* Tidying L035
* Trigger build
* Trigger build
* Add new segment predicate is_keyword()
* New rule: Simplify nested CASE statements
* Use new "is_keyword()" function
* Fix formatting and whitespace issues
* Add "pragma: no cover"
* Fix import
* Doc fixes from PR review
* Get it working with the refactored CASE segment
* Simplify
* Doc fixes from PR review
* Overload Segments [] operator so slicing returns Segments, not tuple
* Rewrite the rule without using apm
* Add property BaseRule.indent, use it in L004
* Add newline
* Add test case file for L058
* Add another test
* Add another test case
* Remove leftovers from the other branch
* Add back a blank line
* Update src/sqlfluff/rules/L058.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Update test/fixtures/rules/std_rule_cases/L058.yml
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
Co-authored-by: Joseph Young <80432516+jpy-git@users.noreply.github.com>
Co-authored-by: jpy-git <josephyoung.jpy@gmail.com>
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Create surrogate classes to simplify rule creation
* Expose surrogates from RuleContext
* Try to fix runtime error occurring in typing.py in Python 3.6
* Make coverage checker happy
* Coverage-related tweaks
* Change how segment attributes are accessed
* Refactor to fix circular dependency
* PR review
* Add common_predicates module with is_meta and is_expandable
* Tweaks
* Convert L021, change Segments to inherit from tuple, add more stuff to Segments
* Remove LintResult and LintFix stuff from Segments
* Move LintResult and LintFix back to base.py
* Rewrite rule L017
* Add Segments.first() and last()
* Rewrite L038
* Rewrite L013
* Undo accidental whitespace removal
* Add "reversed()" method, add some comments
* Change "first()" and "last()" to return a "Segments" instead
* Update L009 to use new surrogates API
* Inherit from list, not tuple. Fix a couple of issues.
* Fix some typing and linter issues
* Try and fix import issue in Python 3.6
* Remove support for Python 3.6
* Remove more references to Python 3.6
* Undo some changes that may be causing weird test failures
* Use relative import for segment_predicates to try and work around Python 3.6 issue
* Revert "Use relative import for segment_predicates to try and work around Python 3.6 issue"
This reverts commit 44cbe3babe3d5f852b6c820d6fe895860c33d085.
* Rename "surrogates" directory as "functional"
* Add "and", "or", and "not" functions, update L009
* Add unit tests for "segments" module
* Add unit tests for "raw_file_slices" module
* Disallow passing strings or classes as Predicates, now they must be functions
* Eliminate "Predicate" alias, use shorter import name for segpred, etc.
* Remove unneeded code
* Simplify code
* Add is_name predicate
* Add get_name predicate
* Fix L009 predicate implementation
* Convert all predicates to closures (for consistency)
* Rename Surrogates as FunctionalRuleContext, add missing properties
* Convert get_type() and get_name() to use closures, change select() parameters to functions, not lists
* Convert L001
* Update L008, add raw_segments property, all segments.py functions take single predicate
* Bug fixes
* Eliminate a temp variable
* Address missing coverage
* Remove "# pragma: no cover" from functions that may need tests
* Update rule development docs to mention the functional API
* Add a test for sp.and_()
* PR review
* Revert "Inherit from list, not tuple. Fix a couple of issues."
This reverts commit 443927cb66fb92d2ac46e9d0cdecf4d514b89bfd.
* Fix a bad import after the revert
* Convert L015
* Change "templated_file" to a keyword-only argument (for convenience of using the classes directly)
* Update L025, fix a test broken by the RawFileSlices API change
* Update test after Segments.__init__() API change
* Update L031
* Tweak L031
* Update L035
* Update L036, add Segments find() and get() functions
* More L036
* More L036
* More L036
* Update L041 to use awesome-pattern-matching
* More L041
* Rules docs
* Fix broken test
* Fix broken test
* Add "pragma: no cover"
* Update L042
* More L042
* Update L043
* Update L047
* Update L049
* More L049
* Clean up type hints
* Update L052
* Bug fix
* Tidying
* Trigger build
* More L017
* Tidying L035
* Trigger build
* Trigger build
* Add new segment predicate is_keyword()
* Use new "is_keyword()" function
* Add "pragma: no cover"
* Fix import
* Doc fixes from PR review
* Overload Segments [] operator so slicing returns Segments, not tuple
* Add property BaseRule.indent, use it in L004
* Update rule docs to mention issues with awesome-pattern-matching
* Add "pragma: no cover"
* L017: Switch from awesome-pattern-matching to functional API
* Revert L041 changes to "main", no longer using awesome-pattern-matching
* Revert L049 changes to "main", no longer using awesome-pattern-matching
* L052: Stop using awesome-pattern-matching, use functional API instead
* Remove awesome-pattern-matching from docs and dependencies
* PR review: Remove apm from mypy.ini
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
Co-authored-by: Joseph Young <80432516+jpy-git@users.noreply.github.com>
Co-authored-by: jpy-git <josephyoung.jpy@gmail.com>
* Split out `CREATE VIEW` into its own statement
* Removed `VIEW` from the general `CreateStatement` in Snowflake.
* Added test cases to support most of the CREATE VIEW functionality
* Added a note w.r.t the complexity involved in column-level
masking policy & tagging config.
* * Re-generated YML
* * Removed duplicate `CREATE VIEW` test cases and consolidated them into `snowflake_create_view`
* * Comment touch-up
* * Fix linting
* * Updated per feedback
* Restructure CASE segment (extract WHEN and ELSE into their own segment types)
* Update YAML parse structure
* Update L035 and L043 after restructuring of CASE segment
* Remove unnecessary OneOf()
* Add suggested test from PR review
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
* update test cases
change file names to better match spark docs
add file for create table like syntax
* create table like synax
* update createTableStatementSegment
updated to use AnyNumberOf instead of specifying LOCATION multiple times
* refresh yml fixtures
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
* Adding Redshift-specific CREATE TABLE AS statement
* Adding CREATE TABLE AS tests
* Changing segment name
* Formatting
* Adding additional tests to redshift
* Changing segment name
* Adding additional tests
* Adding additional tests
* Modifying column reference segment to be bracketed and only take column references, not constraints
* Reverting segment name back
* TSQL: remove dependence on ANSI keyword list
* TSQL: remove dependence on ANSI keyword list
* TSQL: remove dependence on ANSI keyword list
* TSQL: remove dependence on ANSI keyword list
* TSQL: remove dependence on ANSI keyword list
* TSQL: remove dependence on ANSI keyword list
* TSQL: remove dependence on ANSI keyword list
* TSQL: Remove dependency on ANSI keywords
* TSQL: Remove dependency on ANSI keywords
Co-authored-by: jpersons <jpersons@iuhealth.org>
* Grammar: Add SET sql_log_bin statement
* Add BooleanDynamicSystemVariablesGrammar grammar to allow correct capitalisation of ON/OFF and TRUE/FALSE
* Extra boolean SET unit tests
* Grammar: Tidy up USE statements
* Update src/sqlfluff/dialects/dialect_snowflake.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Update src/sqlfluff/dialects/dialect_ansi.py
* black format
* Update dialect_snowflake.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Grammar: Add LISTEN, NOTIFY, and UNLISTEN statements to Postgres dialect
* Update dialect_postgres.py
* Black format
* Update dialect_postgres.py
* Black format
* Grammar: Fix TRUNCATE statement in Postgres dialect
* Update src/sqlfluff/dialects/dialect_postgres.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Black format
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* added struct support for `hive` and `redshift`
* black delint
* renamed mock columns not to use keyword
* quoted `True` values
* reverted back to `True` despite of yamllint violations
* removed doc delimiter
* typo
* changed missed `true` value
* TSQL: Proper Indentation of ELSE IF
* TSQL: Proper Indentation of ELSE IF
* TSQL: Proper Indentation of ELSE IF
* TSQL: Proper Indentation of ELSE IF
Co-authored-by: jpersons <jpersons@iuhealth.org>
Co-authored-by: Joseph Young <80432516+jpy-git@users.noreply.github.com>
* Make L057 compatible with BigQuery
* Better comments
* Another comment improvement
* Tweak layout of L057
* Add bigquery fail wildcard test
Co-authored-by: Joseph Young <80432516+jpy-git@users.noreply.github.com>
Co-authored-by: jpy-git <josephyoung.jpy@gmail.com>
* Fix mypy error on python 3.7
* Fix mypy error on python 3.8
* Cleaner way to fix mypy error
Co-authored-by: Joseph Young <80432516+jpy-git@users.noreply.github.com>
* Hive: add INTERVAL syntax
* Make timeunit aliases recognized as DatetimeUnitSegment
* Detect interval expression correctly
* Add NANO/NANOS timeunit
+ use the original bracketed expr from hive doc
Co-authored-by: Joseph Young <80432516+jpy-git@users.noreply.github.com>
* L039: Add logic to flag and remove spaces within references
* L039: Add logic to flag and remove spaces within references
* L039: Add logic to flag and remove spaces within references
* L039: Add logic to flag and remove spaces within references
* Update src/sqlfluff/rules/L039.py
Co-authored-by: Joseph Young <80432516+jpy-git@users.noreply.github.com>
* Update src/sqlfluff/rules/L039.py
Co-authored-by: Joseph Young <80432516+jpy-git@users.noreply.github.com>
* Update src/sqlfluff/rules/L039.py
Co-authored-by: Joseph Young <80432516+jpy-git@users.noreply.github.com>
* L039: Add logic to flag and remove spaces within references
* L039: Add logic to flag and remove spaces within references
Co-authored-by: jpersons <jpersons@iuhealth.org>
Co-authored-by: Joseph Young <80432516+jpy-git@users.noreply.github.com>
* Run pre-commit hook on all files
* Run pre-commit hook
* Merge main branch
* Regenerate fixtures
* Fix pre-commit hook and mypy
* Exclude more files from pre-commit hook
* Exclude from pre-commit
* Fix regexp for pre-commit exclusion
* Reset path_c
* Exclude path_c file from pre-commit hook
Co-authored-by: Joseph Young <80432516+jpy-git@users.noreply.github.com>
* Exclude path_c file from pre-commit hook
Co-authored-by: Joseph Young <80432516+jpy-git@users.noreply.github.com>
* Dedent
Co-authored-by: Joseph Young <80432516+jpy-git@users.noreply.github.com>
* added array/struct in `default` definition of `declare`
* added `tuple` segment + tests
* reverted `TypelessStruct` and redefined `Tuple`
* corrected `Declare` definition simplified `Tuple`
to cover original syntax with optional datatypes
* corrected `declare` to allow typeless
* removed incorrect case for `declare`
* data_type and default: atleast one should be defined
* simplified `tuple` definition
* simplified `TypelessStruct`
* switched to Grammar object
Co-authored-by: Joseph Young <80432516+jpy-git@users.noreply.github.com>
* Add ability to parse multiple GO/semicolon delimiters
* Remove unnecessary optional
* Add extra unit test to satisfy coverage
* Ignore unused raise in code
* Add test docstring
* Add tests for parsing identifiers in spark3
In Spark SQL, backticks are used for delimited identifiers:
https://spark.apache.org/docs/latest/sql-ref-identifier.html#delimited-identifier
The test with a plain identifier passess but using backticks fails to
parse.
* Separate test cases for delimiters in spark3
* Delimited identifiers in spark3 use backticks
* Show that it's still broken in CTEs
* Don't address CTE for now
* Must version control fixture yaml
* Whitespace
* Remove test case at reviewer's request
* Patch backquote regex per reviewer's suggestion
* Ensure escaped backticks in aliases are covered
* Test cases with many backticks, and a more accurate regex
* Regenerate yaml
* Blacken to remove errant newline
Co-authored-by: Joseph Young <80432516+jpy-git@users.noreply.github.com>
* RegexParser no longer uppercases templates
* Add Snowflake CREATE AND ALTER STAGE statements
* Make Snowflake external stage parameters optional
* Fix docstring for InternalStageParameters
* PR review improvements for Snowflake CREATE and ALTER stage
Co-authored-by: Joseph Young <80432516+jpy-git@users.noreply.github.com>
* Grammar: Adds support for ALTER VIEW statement for Postgres dialect
* Update src/sqlfluff/dialects/dialect_postgres.py
Co-authored-by: Joseph Young <80432516+jpy-git@users.noreply.github.com>
* Introduce dbt 1.0.0 and update old references.
* Fix profiles dir import issues
* Fix a couple more errors
* Choose dbt_utils version based on the dbt version, change how we check if a model is disabled (#2087)
* Choose dbt_utils version based on the dbt version
* Skip the script if dbt templater is not installed
* In dbt 1.0, need to look up disabled models a different way
* Add fixture for changed whitespace in dbt_utils 0.8.0
* Database connection failures raise an exception in dbt 1.0.0
* Lint
* Some tweaks suggested in the PR review (#2088)
* Some tweaks suggested in the PR review
* Empty commit
Co-authored-by: Niall Woodward <niall@niallrees.com>
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* 1928 add tests for TSQL MERGE statement
* 1928 add TSQL MERGE statement
* closes 1982: add requirement to have at lease one MERGE WHEN MATCHED or MERGE WHEN NOT MATCHED in MERGE statement
* Add ability to use default and extra config files in simple API
* Refined code and added unit test
* Fix docstrings
* Update src/sqlfluff/api/simple.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Improve coverage
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Add ON DELETE/ON UPDATE clause for table constraints
* Restore files
* Restore files
* Keywords fixed
* Running pre-commit
* Fix review problems
* More tests
* Format
* Use all constraint options for better test coverage
Co-authored-by: Joseph Young <80432516+jpy-git@users.noreply.github.com>
* Update expected result
Co-authored-by: Joseph Young <80432516+jpy-git@users.noreply.github.com>
* Fix L043 issue when trying to autofix functions
* Update src/sqlfluff/rules/L043.py
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Add memory to log previously fixed commas in L008
* Add new L008 logic
* Use raw_segments for most robust fix
* coverage
* satisfy coverage
* Extra unit test for coverage of unused method
* Implement review feedback
* TSQL: Fix CTAS with WITH statement
* TSQL: Fix CTAS with WITH statement
Co-authored-by: jpersons <jpersons@iuhealth.org>
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
* L044 should handle nested CTEs
* Linter, Black
* "No cover" for debugging code
* Clean up duplicate code
* mypy
* Readability
* Add test, fix a bug it uncovered
* Add more tests, as suggested in PR review
* More tests
* Interim checkin of big SelectCrawler refactoring
* Fix some broken tests
* Create a new class "Selectable" to help handle nested SELECTs
* Ensure "queries" stack is popped correctly
* Fix some bugs with aliases and nested SELECTs
* CTE lookup should check parent scopes
* Cleanup: Remove unnecessary "dialect" parameter from some functions
* Refactor/rename the SelectCrawler API a bit
* Remove unused import, also debug print statements
* Linter, comments
* Update L045 to work with new SelectCrawler
* flake8, Black
* mypy
* Rename "remove_sources" parameter as "pop" for consistency
* Tidy up comment
* Oops, renamed this
* Black
* Remove unused code
* Remove unused code
* Comments, readability
* More comments
* More comments
* Add more tests as suggested by reviewer
* Black
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
Co-authored-by: Joseph Young <80432516+jpy-git@users.noreply.github.com>
* 🗄️ Cache dependencies for CI
* 🐛 Use actual python version in cache key
* 🐛 Move env out of steps
* 🙅 Dont use env in step names
* ⚡ Speed up tests with parallel processing
* 2️⃣ Explicitly use two processors to run tests
I need to auto discover the first time since I didn't know how many GitHub made available. Now that we know it's just two, we can be explicit
* 🔀 Use setup.py and requirement_dev.txt for caching
* 🙅 Undo caching changes
* ⬆️ Bump python version for dbt tests
This worked locally for me, and the only difference I could tell between my environment and the GitHub action environment is that I ran tox with python 3.9 instead of 3.8, so we're going to try that 🤷♂️
* ↩️ Undo python version changes
* Use posargs to enable pytest_xdist for standard unit tests only (#2003)
* Use posargs to enable pytest_xdist for standard unit tests only
* Include standard windows tests
Co-authored-by: Joseph Young <80432516+jpy-git@users.noreply.github.com>
* Add ability to include and exclude rules via globs
* Unit tests
* Black reformat
* Add validation for mixing glob and non-glob rules to unit tests
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Fix issue with inline ignores not respecting comment lines
* Add unit tests
* Black reformat
* Include block/hash comment tests
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Apply final newline fix at the file segment child level for correct parse tree
* Black reformat
* Algorithm to ensure end of tree
* catch parent_stack edge case
* Introduce create_after edit type
* remove test file
* resolve outstanding unit tests
* Move end of file detection algo to BaseRule
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Add type hints to simple API
* Add py.typed file
* Move py.typed from MANIFEST.in to setup.cfg
* Deprecate str rule params in simple API
* Black reformat
* Remove unused import
* Deprecate str rule params in Linter
* Rule: No special characters in names
* black
* Rule: No special characters in names
* Rule: No special characters in names
* Rule: No special characters in names
* Rule: No special characters in names
* Rule: No special characters in names
* Rule: No special characters in names
* Rule: No special characters in names
* Rule: No special characters in names
* Rule: No special characters in names
* Rule: No special characters in names
* Rule: No special characters in names
* Rule: No special characters in names
* Rule: No special characters in names
* Rule: No special characters in names
* Rule: No special characters in names
* Rule: No special characters in names
* Rule: No special characters in names
* Rule: No special characters in names
* Rule: No special characters in names
* Rule: Special Characters in names: code review results
* Rule: Special Characters in names: code review results
* Rule: Special Characters in names: code review results
* Rule: Special Characters in names: code review results
* Rule: Special Characters in names: code review results
* Rule: Special Characters in names: code review results
* Rule: Special Characters in names: code review results
* Rule: Special Characters in names: code review results
Co-authored-by: jpersons <jpersons@iuhealth.org>
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Add Dockerfile and Github Actions workflow for Official Docker image
* Update Dockerfile
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Update docker build comments
* Fix spelling mistake
* Official docker test (#2)
* Refactor Dockerfile for better caching performance; add .dockerignore.
* Implement layer caching in GHA.
Co-authored-by: Chris Curro <git@curro.cc>
* revert requirements.txt to be handled by #1956
* make docker image test consistent with suggested usage
* Add README reference to Official SQLFluff Docker Image
* Set separate end-user working directory for convenience
* remove -t option in integration test
* Add workflow_dispatch option incase we manually want to trigger docker build and push
* Extract dependencies from setup.cfg
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
Co-authored-by: Chris Curro <git@curro.cc>
* Move typing_extensions requirement from requirements_dev.txt to requirements.txt
* re-add oyaml comment
* reorder dependencies in requirements.txt and setup.py
* Add support for SnowSQL ampersand variables
* Add support for SnowSQL ampersand variables
* Move snowsql variables to placeholder templater
* Clean up tests
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* New Rule L056: 'SP_' prefix should not be used for user-defined stored procedures in T-SQL.
* Add extra test cases for bracketed/quoted stored procedure names
* Fix unescaped underscores in L056 docstring
* raw docstrings to satisfy flake8 + sphinx
* Remove unnecessary lists
* Use description param of LintResult to avoid escape backslash in docstring from showing during linting
* Black reformat
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
* Add rule to remove outer brackets on SQL statements.
* Add unit test for L053
* Add tsql specific logic
* Update src/sqlfluff/rules/L053.py
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Exclude meta from bracket substitution
* Extra unit tests to validate non top-level brackets
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Add L053 to ensure no implicit positional column references in GROUP BY clause
* Initial L053 fix thoughts
* initial fix logic
* Revert to Lint only
* Implement code review feedback
* Make consistent GROUP BY/ORDER BY references the default in L054
* Black format
* Implement code review feedback
* Extra test cases
* implement bug fix from code review
* Remove test case from wrong branch
* Added tablesample support to bigquery
* linting
* Added Drop Function support to Postgres and T-SQL
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
* Update tox configuration, as well as CONTRIBUTING.md
* moved types-chardet from requirements.txt to requirements_dev.txt
* Update CONTRIBUTING.md
Co-authored-by: Alan Cruickshank <alanmcruickshank@gmail.com>
* Update CONTRIBUTING.md
Co-authored-by: Alan Cruickshank <alanmcruickshank@gmail.com>
Co-authored-by: Alan Cruickshank <alanmcruickshank@gmail.com>
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
* initial implementation
* Move coalesce fix logic into a common function
* Update src/sqlfluff/rules/L043.py
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Refinement on detecting lone condition logic
* Extra unit tests to catch potential false positives
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Fix bug where "sqlfluff fix" deletes dbt "{% snapshot %}" line
* Parametrize an existing test and add a new case
* Linter, tidying, add test files
* Add more detail to docstring
* Clean up "FIXED" files both before and after
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
* Fix bug where L016 places newlines in the parse structure that confuse L016
* Refine the L041 filter logic so L016 doesn't confuse it
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
* Implement generic placeholder templating
* Add %s placeholder too
* Add tests and check for the config state
* Remove typo and improve wording of the documentation for placeholder
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
* Initial L036 refinements - TODO: Handle SELECT statements with no from clause
* Fixed L036 for no FROM clause
* Update unit test
* implement code review feedback
* Updates to COPY INTO grammar in Snowflake
* Added docstring
* linting
* Bugfix
* Regen test cases
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
* [issue_1841] handle rendering progressbar among lint errors
* [issue_1841] progressbar can be now rendered even in verbose mode
* [issue_1841] weave tqdm into logger handler to avoid conflicts with progressbars
There was still an issue with DEBUG mode (when called with -vvv).
* [issue_1841] ignore coverage for exception handling in overloaded function
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Allow plain AUTOINCREMENT in Snowflake dialect
* Simplify to use optional=True on existing OneOf
* Add naked AUTOINCREMENT test case to snowflake_create_table.sql
* Remove plaintext API key from benchmark utility
* Add missing $ before GH secret ref
* moving SQLFLUFF_BENCHMARK_API_KEY env call before post request
Co-authored-by: Alan Cruickshank <alanmcruickshank@gmail.com>
* Add OVERRIDING SYSTEM/USER VALUE to insert statement in postgres dialect
* generated test yaml
* Add link to postgres 14 INSERT docs
* remove optional INTO in ANSI INSERT, moved to bigquery dialect
* fix lint + extra big query test
* lint fix
Co-authored-by: Danny Jones <51742311+WittierDinosaur@users.noreply.github.com>
* Issue 1437: Implement a robust Jinja raw <---> templated mapping
* Copy PythonTemplater.slice_file() to JinjaTemplater
* Prototype new Jinja template mapping approach
* Handle "templated" type by evaluating but outputting a UUID
* Rename the field: kindred_raw -> unique_alternate
* Tidying, renaming
* Add angle brackets around UUID, fix bug where it wasn't returning UUID
* Add and popuate RawFileSlice.next_slice_indices
* First prototype of TemplateTracer
* Passes a test!
* Add handling for the case where multiple templated parts are returned at once by generate()
* More bug fixes
* Get all the test__templater_jinja_slices tests updated & working
* Fix test__templater_jinja_error_variable
* Fix a subtle bug that confounded int length with actual templated text
* Fix bug handling "raw" Jinja blocks
* Bug fix: Not popping stack on "endif" or "endfor"
* Fix bugs involving {% set %}
* Handle both flavors of Jinja "set" command
* Handle where Jinja gives us multiple sections of output at once
* Fix bug checking templated file slice
* More rework of how to generate and process alt template output
* Split alt template output on NUL ("\0") characters
* Fix right whitespace stripping case
* All the test__templater_jinja_slice_template tests are now working
* Fix a few tests
* Fix some more tests
* Update a test with new results (more refined than before)
* Update a test whose results have (I think legitimately) changed
* When looping, don't repeat the {% for %} TemplatedFileSlice
* Fix some integration issues related to RawFileSlice switching from NamedTuple to dataclass
* Linter
* Update Python tests affected by RawFileSlice changes
* Updated test result -- looks better now!
* Move the internal error check _inside_ the loop
* Generate nicer placeholder strings for omitted code
* Tweak placeholder gap output, update expected test output
* Indentation improvements for templated code
* Tweaks to L003 to avoid breaking non-templated indentation
* Update existing L003 tests, add a new one
* More work on L003
* Tidying
* Streamlining
* Tidying
* Comments, tidying
* Tidying
* Mypy
* PR review
* Rename MetaSegment.template as MetaSegment.is_template
* Refactor: Move tracer class to a new module, tidy up interface with JinjaTemplater
* mypy
* Update test result
* Update test result
* mypy
* Fix DbtTemplater; it needed the old Jinja _slice_template() function
* Black, mypy
* Linter
* mypy
* Add a few "no cover" comments
* Add "no cover" comments, remove unused L003 code
* Move tracer-specific RawFileSlice fields into a dictionary
* Black, mypy
* mypy
* Update DbtTemplater to use JinjaTracer
* Add "no cover" comments for code "uncovered" by this PR
* Add "no cover" comment
* Comments
* Linter
* Add missing __init__.py file
* Add docstring
* mypy
* Add 1 1/2 dbt templater tests
* Update test so it doesn't require a database
* Fix broken test
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
Co-authored-by: Alan Cruickshank <alanmcruickshank@gmail.com>
* Postgres: Allow quoted identifiers in ALTER TABLE OWNER TO
* Allow both quoted and unquoted identifiers in ALTER TABLE OWNER TO
* Add tests for Postgres ALTER TABLE OWNER TO
* added L050 rule to remove starting whitespace
* fixed failing unit test due to unintended indentation
* Update L050 docstring
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* remove newline
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Update test/fixtures/rules/std_rule_cases/L050.yml
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* adding additional docstring example
* removed unintentional memory dict
* skip L050 for unaccounted source slice gaps
* skip L050 for unaccounted templated slice gaps
* skip L050 for preceding source only slices
* skip L050 for intersecting templated raw slices
* removed unused import
* Update src/sqlfluff/rules/L050.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* made logic more clear
* adjusted linting
* added extra unit tests
* replaced ampersand with and
* replaced temporary set with generator expression
* reseting test__rules__std_L003_L036_L039 and excluding L050
* added custom unit tests to verify that L050 is affected by ignore_templated_areas in the config
* accounting for new exclude_rules param in simple api
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* Add exclude_rule option for the Simple API
* Update test/api/simple_test.py
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* Add test to ensure pip install works
* Fix test
* Fix test take 2
* Fix test
* Another attempt
* Fix test (again!)
* Fix typo
* Fix label
* Add comment
* Add more tests
* Fix: add tqdm to setup installation requirements
Fix a bug introduced in v0.8.0, where pip installing sqlfluff and then
running any sqlfluff command results in the error:
"ModuleNotFoundError: No module named 'tqdm'".
* Unpin the version of tqdm
Remove the requirement for tqdm to be pinned at version 4.62.3 from
setup.py, requirements.txt, and docs/requirements.txt.
* Added changes to docs
* Applying edits
* More fixes
* More changes
* More fixes
* More fixes
* More additions
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
* updated L009 logic to only allow a single trailing newline
* moved L009 test cases from python to yml
* updated anchor_segment logic
* Update src/sqlfluff/rules/L009.py
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* fixing dbt unit tests for L009 update
* black tweaks
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
* [issue_1536] introduced tqdm
* [issue_1536] progress bar can be disabled by dedicated parameter
* [issue_1536] add dedicated tests for progress bars
* [issue_1536] remove __future__.annotations because py3.6
+ add tqdm into docs/requirements.txt
* [issue_1536] disables progressbar when in verbose mode
* should install tqdm for example tests in CI
* [issue_1536] satisfy black
* [issue_1536] fix one more test
* [issue_1536] tqdm should handle displaing progressbar on different output types
* [issue_1536] progressbar for matching and parsing
* [issue_1536] move progressbar disable control to kind of singleton configuration
It makes easier whole passing disable_progress_bar flag
* [issue_1536] satisfy flake8
* [issue_1536] add some comments
* [issue_1536] fix pb disabling for nonTTy envs
To avoid overwriting disable (when set to None which means to be maintaned automatically) by additional conditions, their orders were modified.
`disable=progress_bar_configuration.disable_progress_bar or files_count <= 1` should be `disable=files_count <= 1 or progress_bar_configuration.disable_progress_bar`
* [issue_1536] patch properly progressbar disable state in tests
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
* add initial passing tests
* aliased tests
* run black
* add unreserved keywords and rename type for expression segments
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
* Allow SELECT column alias in WHERE clauses for certain dialects
* Remove unnecessary change
* Update src/sqlfluff/rules/L028.py
Co-authored-by: Alan Cruickshank <alanmcruickshank@gmail.com>
* Fix internal error in L016 when template/whitespace-only line too long
* Added "no cover" comment
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
* Issue 1437: Implement a robust Jinja raw <---> templated mapping
* Copy PythonTemplater.slice_file() to JinjaTemplater
* Prototype new Jinja template mapping approach
* Handle "templated" type by evaluating but outputting a UUID
* Rename the field: kindred_raw -> unique_alternate
* Tidying, renaming
* Add angle brackets around UUID, fix bug where it wasn't returning UUID
* Add and popuate RawFileSlice.next_slice_indices
* First prototype of TemplateTracer
* Passes a test!
* Add handling for the case where multiple templated parts are returned at once by generate()
* More bug fixes
* Get all the test__templater_jinja_slices tests updated & working
* Fix test__templater_jinja_error_variable
* Fix a subtle bug that confounded int length with actual templated text
* Fix bug handling "raw" Jinja blocks
* Bug fix: Not popping stack on "endif" or "endfor"
* Fix bugs involving {% set %}
* Handle both flavors of Jinja "set" command
* Handle where Jinja gives us multiple sections of output at once
* Fix bug checking templated file slice
* More rework of how to generate and process alt template output
* Split alt template output on NUL ("\0") characters
* Fix right whitespace stripping case
* All the test__templater_jinja_slice_template tests are now working
* Fix a few tests
* Fix some more tests
* Update a test with new results (more refined than before)
* Update a test whose results have (I think legitimately) changed
* When looping, don't repeat the {% for %} TemplatedFileSlice
* Fix some integration issues related to RawFileSlice switching from NamedTuple to dataclass
* Linter
* Update Python tests affected by RawFileSlice changes
* Updated test result -- looks better now!
* Move the internal error check _inside_ the loop
* Generate nicer placeholder strings for omitted code
* Tweak placeholder gap output, update expected test output
* Indentation improvements for templated code
* Tweaks to L003 to avoid breaking non-templated indentation
* Update existing L003 tests, add a new one
* More work on L003
* Tidying
* Streamlining
* Tidying
* Comments, tidying
* Tidying
* Mypy
* PR review
* Rename MetaSegment.template as MetaSegment.is_template
* Refactor: Move tracer class to a new module, tidy up interface with JinjaTemplater
* mypy
* Update test result
* Update test result
* mypy
* Fix DbtTemplater; it needed the old Jinja _slice_template() function
* Black, mypy
* Linter
* mypy
* Add a few "no cover" comments
* Add "no cover" comments, remove unused L003 code
* Move tracer-specific RawFileSlice fields into a dictionary
* Black, mypy
* mypy
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
* [WIP] Working on CreateTableAsStatementSegment
* [WIP] Working on CreateTableAsStatementSegment
* Adding tests for CREATE TABLE AS to postgres_test.py
* [WIP] Working on CreateTableAsStatementSegment
* [WIP] Working on CreateTableAsStatementSegment
* [WIP] Working on CreateTableAsStatementSegment
* [WIP] Adding optionally bracketed to CreateTableAsStatementSegment.
* [WIP] Adding CreateTableAsStatementSegment to StatementSegment and breaking up "ON COMMIT" into two words in Sequence.
* Removing test, adding postgres_create_table_as.sql
* Adding postgres_create_table_as.yml
* Removing comments and adding TODO
* Formatting using Black
* Changing "PRESERVE ROWS" and "DELETE ROWS" into Sequences.
* Adding TABLE, VALUES, and EXECUTE to statement.
* Removing redundant optional statements, column constraints and formatting.
* Adding line to allow for `Ref("TemporaryGrammar")` to be used alone or with "GLOBAL" or "LOCAL"
* Formatting.
* Changing USING statement to take parameter instead of function.
* Changing bracket logic around SELECT, VALUES, TABLE, and EXECUTE statement
* Adding several tests based on new logic.
* Adding optional back to GLOBAL, LOCAL
* De-nesting elements of "WITH" statement.
* Removing redundant Sequence statement from `CreateTableStatementSegment`
* Re-adding WITH statement logic as it was before.
Co-authored-by: Danny Jones <51742311+WittierDinosaur@users.noreply.github.com>
* Replaced generators with list comprehensions
* More performance improvements
* Remove test files
* Fixed failing tests
* linting
* linting
* Removed redundant commented code
* Removed dead functions, added docstring
* Style changes
* linting
* Added return None option to _first_non_whitespace
* Removed unnecessary try-except
* Added SQLFLUFF_TESTENV bar to tox, used it in Sequence
* linting
* Added test case
* Added check that testenv is set to testenv-specific test
Co-authored-by: Alan Cruickshank <alanmcruickshank@gmail.com>
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
sqlfluff-templater-dbt dependency on dbt ends up pulling
dbt-postgres, dbt-redshift, dbt-snowflake and dbt-bigquery
which are all pretty large. This commit changes the dependency
to dbt-core instead.
* "sqlfluff fix": Write to a temporary .sql file first
* Use shutil.move() so it works on Windows too
* mypy
* Refactor into separate function, add test
* Forgot to commit the test
* Linter (add docstring)
* Remove "type: ignore: comment mypy says isn't needed (?!)
* Ensure the temporary file is written to disk before using it
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
* feat: support hive left semi join
* fix: fix sql style for left semi join
* fix: fix mysql drop index lint
* feat: enhance mysql drop index
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
* add spark keywords
* add data sources
add core and popular community contributed data sources as non-reserved keywords
* add spark3 for dialect lookup
* rename to emphasize spark3
* alter database and alter view
* fix typo
* refactor spark_dialect to spark3_dialect
* [unit tests] AlterDatabaseStatementSegment
* [unit tests] ALTER TABLE
RENAME TO table_identified
RENAME partition_spec
* [unit tests] ALTER TABLE
ADD COLUMNS
* add back the 'add column' unit test'
'
* [unit test] ALTER TABLE
CHANGE COLUMN
* [Unit Test] ALTER TABLE
ADD PARTITION
* [unit tests] ALTER TABLE
DROP PARTITION
* add support and unit test for adding multiple partitionsl
* [unit tests] ALTER TABLE
SET and UNSET TBL PROPERTIES
* [unit tests] ALTER TABLE
SET SERDE & SET FILEFORMAT
* [unit tests] ALTER TABLE
Change File Location
* additional unit test for file location and serde
* alter column unit test
* Implement and test ALTER VIEW
* implement and unit test CREATE DATABASE
* implement and unit test CREATE FUNCTION
* implement and unit test create datasource table
* adding files for troubleshooting
* most recent changes for troubleshooting
* most recent changes to troubleshoot missing FileSegment
* pushing most recent changes for troubleshooting
* adding MAP data type to test case back in
* fix closing bracket not found parsing error
adding yml files from unit testing
* minor reformat
* refactor spark3 keywords file name
* refactor spark3 keywords file
* update docs for Spark3
* resolve linting errors
* black formatting and fixed flake8 linting errors
* Update src/sqlfluff/dialects/dialect_spark3.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* cleaning up commented out code
* remove TODO for StoredAsGrammar and add clarifying comments
* add spark3 to README.md and setup.py
Co-authored-by: Danny Jones <51742311+WittierDinosaur@users.noreply.github.com>
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
* TSQL: split location clause out from index clause
* TSQL: split location clause out from index clause
* TSQL: split location clause out from index clause
Co-authored-by: Danny Jones <51742311+WittierDinosaur@users.noreply.github.com>
* TSQL: Override HAVING
* TSQL: Override HAVING
* TSQL: Override HAVING
* Update src/sqlfluff/dialects/dialect_tsql.py
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
* TSQL: CTAS select can be optionally bracketed
* TSQL: Add DROP STATISTICS, fix DROP INDEX
* TSQL: Add DROP STATISTICS, fix DROP INDEX
* TSQL: Add DROP STATISTICS, fix DROP INDEX
* Issue 1437: Robust Jinja raw/templated slice mapping
* Parametrize the test
* Add a basic (no whitespace control) test case
* Now correctly handling block_start whitespace stripping
* Add test case
* Enhance test case
* Handle variables with whitespace stripping, add a test for it
* Tidying, update test case
* Handle comments
* Add test for issue 1608
* Fix some things that were causing lint messages
* The test for this issue needs to run "fix"
* Add missing file, update .gitignore
* "no cover"
* Trigger build
* PR review, "no cover"
* Add two more test cases, basic_data and strip_right_data
* PR review
* More comments on the algorithm
* More comments
* Handle right whitespace stripping similarly as left
* Test updates
* Remove test case changes that were added in this PR and stopped working when I added handling for right whitespace stripping
* Add "pragma no cover"
* Change how I'm doing "pragma: no cover" to be simpler/safer
Co-authored-by: Barry Hart <barry.hart@mailchimp.com>
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
* 0.7.0 Release
* Update CHANGELOG.md
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
* Add breaking notice to changelog and links to docs
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
* src/sqlfluff/core/linter: Improve ignore file processing
- Don't re-scan entire directories for every sqlfluffignore
- Fix crashes due to recursive symlinks
- Improve warning when an exact file is ignored
* src/sqlfluff/core/linter/linter: Move an assignment outside a loop
Co-authored-by: Alan Cruickshank <alanmcruickshank@gmail.com>
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
Co-authored-by: Alan Cruickshank <alanmcruickshank@gmail.com>
* Stop rule L048 complaining if literal is followed by a semicolon for the end of the statement
* Linting
* Review feedback
Co-authored-by: Alan Cruickshank <alanmcruickshank@gmail.com>
* Fix TSQL DECLARE and SET statements to fully parse expression assignments
* Fix TSQL DECLARE and SET statements to fully parse expression assignments
Co-authored-by: jpersons <jpersons@iuhealth.org>
* TSQL: Allow for multiple statements in a procedure
* TSQL: Allow for multiple statements in a procedure
* TSQL: Allow for multiple statements in a procedure
Co-authored-by: jpersons <jpersons@iuhealth.org>
* L031 desc updated to cover both 'from' and 'join'
L031 description updated to cover both 'from' and 'join' clauses - previously was a bit confusing as it only mentioned 'join' clauses but will also trigger when there is no join present. Related to https://github.com/sqlfluff/sqlfluff/issues/1624
* Update description of L31 in cli/commands_test.py
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
* FIx broken block comments in exasol
* Allow adding a global test config per testcase
* Respect config per testcase
* Allow adding a global test config per testcase
* Respect config per testcase
* add testcase
* make unittest description more meaningful
Co-authored-by: Alan Cruickshank <alanmcruickshank@gmail.com>
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
* Fixes for using inline dollar signs for identifiers
* Add tests
* Remove accidentally committed class
* Remove the correct accidentally commited class
* Fixes
* Issue #1554: Postgres dialect: Parse error for "on delete" in column constraint
* Fix for UPDATE keyword and update tests
Co-authored-by: Alan Cruickshank <alanmcruickshank@gmail.com>
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
* Better error handling for when not installed
* Update readme and documentation
* Bump version number
* Adjust working directory of plugin build dir
* Remove dependency on core config.ini file
* Update src/sqlfluff/cli/commands.py
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
2021-10-11 22:41:04 +01:00
5534 changed files with 457319 additions and 73415 deletions
_If this is a parsing or linting issue, please include a minimal SQL example which reproduces the issue, along with the `sqlfluff parse` output, `sqlfluff lint` output and `sqlfluff fix` output when relevant._
## Expected Behaviour
## Observed Behaviour
## Steps to Reproduce
## Dialect
## Version
Include the output of `sqlfluff --version` along with your Python version
about: Report an issue with our documentation to help improve SQLFluff
labels: documentation
---
_Use this template to report issues or suggest changes to our documentation on GitHub, on our [Documentation Website](https://docs.sqlfluff.com/) or inline help and error messages shown when running SQLFluff (please note non-documentation issues should be reported using the Bug template or the Enhancement template)._
## URL or Command Line Option with the issue being reported
about: Suggest an enhancement to help improve SQLFluff
labels: enhancement
---
_Note: This is for general enhancements to the project. Please use the Bug report template instead to raise parsing/linting/syntax issues for existing supported dialects_
_Firstly, thanks for adding this feature! Secondly, please check the key steps against the checklist below to make your contribution easy to merge._
<!--Thanks for adding this feature!-->
_Please give the Pull Request a meaningful title (including the dialect this PR is for if it is dialect specific), as this will automatically be added to the release notes, and then the Change Log._
<!--Please give the Pull Request a meaningful title for the release notes-->
### Brief summary of the change made
_If there is an open issue for this, then please include `fixes #XXXX` or `closes #XXXX` replacing `XXXX` with the issue number and it will automatically close the issue when the pull request is merged. Alternatively if not fully closed you can say `makes progress on #XXXX` to create a link on that issue without closing it._
...
<!--Please include `fixes #XXXX` to automatically close any corresponding issue when the pull request is merged. Alternatively if not fully closed you can say `makes progress on #XXXX`.-->
### Are there any other side effects of this change that we should be aware of?
...
### Pull Request checklist
- [ ] Please confirm you have completed any of the necessary steps below.
- Included test cases to demonstrate any code changes, which may be one or more of the following:
-`.yml` rule test cases in `test/fixtures/rules/std_rule_cases`.
-`.sql`/`.yml` parser test cases in `test/fixtures/parser` (note YML files can be auto generated with `python test/generate_parse_fixture_yml.py` or by running `tox` locally).
-`.sql`/`.yml` parser test cases in `test/fixtures/dialects` (note YML files can be auto generated with `tox -e generate-fixture-yml`).
- Full autofix test cases in `test/fixtures/linter/autofix`.
For more information on adding and running test cases see the [Parser Test README](test/fixtures/parser/README.md) and the [Rules Test README](test/fixtures/rules/std_rule_cases/README.md).
For more information on adding and running test cases see the [Parser Test README](test/fixtures/dialects/README.md) and the [Rules Test README](test/fixtures/rules/std_rule_cases/README.md).
#### Running dbt templater tests in Docker Compose
NOTE: If you prefer, you can develop and debug the dbt templater using a
Docker Compose environment. It's a simple two-container configuration:
*`app`: Hosts the SQLFluff development environment. The host's source
directory is mounted into the container, so you can iterate on code
changes without having to constantly rebuild and restart the container.
*`postgres`: Hosts a transient Postgres database instance.
Steps to use the Docker Compose environment:
* Install Docker on your machine.
* Run `plugins/sqlfluff-templater-dbt/docker/startup` to create the containers.
* Run `plugins/sqlfluff-templater-dbt/docker/shell` to start a bash session
in the `app` container.
Inside the container, run:
```
py.test -v plugins/sqlfluff-templater-dbt/test/
```
### Pre-Commit Config
For development convenience we also provide a `.pre-commit-config.yaml` file
to allow the user to install a selection of pre-commit hooks by running (check
the [requirements](#requirements) before running this):
```
tox -e pre-commit -- install
```
These hooks can help the user identify and fix potential linting/typing
violations prior to committing their code and therefore reduce having to deal
with these sort of issues during code review.
### Documentation Website
Documentation is built using Sphinx with some pages being built based on the source code.
See the [Documentation Website README.md](./docs/README.md) file for more information on how to build and test this.
Documentation is built using Sphinx with some pages being built based on the
source code. See the [Documentation Website README.md](./docs/README.md) file
for more information on how to build and test this.
### Building Package
@@ -157,27 +304,97 @@ New versions of SQLFluff will be published to PyPI automatically via
As further PRs are merged, we may need to rerun the release script again
(or alternatively just manually updating the branch). This can only be rerun
locally (the GitHub Action will exit error if the branch already exists to
prevent overwriting it).
Check out the release branch created by the GitHub Action locally and run
the script. It will preserve any `Highlights` you have added and update the
other sections with new contributions. It can be run as follows (you will
need a [GitHub Personal Access Token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) with "repo" permission):
```shell
source .venv/bin/activate
exportGITHUB_REPOSITORY_OWNER=sqlfluff
exportGITHUB_TOKEN=gho_xxxxxxxx # Change to your token with "repo" permissions.
python util.py release 2.0.3 # Change to your release number
```
Below is the old list of release steps, but many are automated by the process
described above.
- [ ] Change the version in `setup.cfg` and `plugins/sqlfluff-templater-dbt/setup.cfg`
- [ ] Update the stable_version in the `[sqlfluff_docs]` section of `setup.cfg`
- [ ] Copy the draft releases from https://github.com/sqlfluff/sqlfluff/releases
to [CHANGELOG.md](CHANGELOG.md). These draft release notes have been created
by a GitHub Action on each PR merge.
- [ ] If you pretend to create a new draft in GitHub and hit "Auto Generate Release
Notes", then it will basically recreate these notes (though in a slightly
different format), but also add a nice "First contributors" section, so can
copy that "First contributors" section too and then abandon that new draft
**SQLFluff** is a dialect-flexible and configurable SQL linter. Designed with ELT applications in mind, **SQLFluff** also works with Jinja templating and dbt. **SQLFluff** will auto-fix most linting errors, allowing you to focus your time on what matters.
**SQLFluff** is a dialect-flexible and configurable SQL linter. Designed
with ELT applications in mind, **SQLFluff** also works with Jinja templating
and dbt. **SQLFluff** will auto-fix most linting errors, allowing you to focus
your time on what matters.
## Table of Contents
1. [Dialects Supported](#dialects-supported)
2. [Templates Supported](#templates-supported)
3. [VS Code Extension](#vs-code-extension)
4. [Getting Started](#getting-started)
5. [Documentation](#documentation)
6. [Releases](#releases)
7. [SQLFluff on Slack](#sqlfluff-on-slack)
8. [SQLFluff on Twitter](#sqlfluff-on-twitter)
9. [Contributing](#contributing)
10. [Sponsors](#sponsors)
## Dialects Supported
Although SQL is reasonably consistent in its implementations, there are several different dialects available with variations of syntax and grammar. **SQLFluff** currently supports the following SQL dialects (though perhaps not in full):
Although SQL is reasonably consistent in its implementations, there are several
different dialects available with variations of syntax and grammar. **SQLFluff**
currently supports the following SQL dialects (though perhaps not in full):
- ANSI SQL - this is the base version and on occasion may not strictly follow the ANSI/ISO SQL definition
- ANSI SQL - this is the base version and on occasion may not strictly follow
the ANSI/ISO SQL definition
- [Athena](https://aws.amazon.com/athena/)
- [BigQuery](https://cloud.google.com/bigquery/)
- [ClickHouse](https://clickhouse.com/)
- [Databricks](https://databricks.com/) (note: this extends the `sparksql` dialect with
We aim to make it easy to expand on the support of these dialects and also add other, currently unsupported, dialects. Please [raise issues](https://github.com/sqlfluff/sqlfluff/issues) (or upvote any existing issues) to let us know of demand for missing support.
We aim to make it easy to expand on the support of these dialects and also
add other, currently unsupported, dialects. Please [raise issues](https://github.com/sqlfluff/sqlfluff/issues)
(or upvote any existing issues) to let us know of demand for missing support.
Pull requests from those that know the missing syntax or dialects are especially welcomed and are the question way for you to get support added. We are happy to work with any potential contributors on this to help them add this support. Please raise an issue first for any large feature change to ensure it is a good fit for this project before spending time on this work.
Pull requests from those that know the missing syntax or dialects are especially
welcomed and are the question way for you to get support added. We are happy
to work with any potential contributors on this to help them add this support.
Please raise an issue first for any large feature change to ensure it is a good
fit for this project before spending time on this work.
## Templates Supported
SQL itself does not lend itself well to [modularity](https://docs.getdbt.com/docs/viewpoint#section-modularity), so to introduce some flexibility and reusability it is often [templated](https://en.wikipedia.org/wiki/Template_processor) as discussed more in [our modularity documentation](https://docs.sqlfluff.com/en/stable/realworld.html#modularity).
SQL itself does not lend itself well to [modularity](https://docs.getdbt.com/docs/viewpoint#section-modularity),
so to introduce some flexibility and reusability it is often [templated](https://en.wikipedia.org/wiki/Template_processor)
as discussed more in [our modularity documentation](https://docs.sqlfluff.com/en/stable/perma/modularity.html).
- [Extension in VS Code marketplace](https://marketplace.visualstudio.com/items?itemName=dorzey.vscode-sqlfluff)
# Getting Started
To get started, install the package and run `sqlfluff lint` or `sqlfluff fix`.
@@ -52,39 +105,77 @@ To get started, install the package and run `sqlfluff lint` or `sqlfluff fix`.
```shell
$ pip install sqlfluff
$ echo" SELECT a + b FROM tbl; " > test.sql
$ sqlfluff lint test.sql
$ sqlfluff lint test.sql --dialect ansi
==[test.sql] FAIL
L: 1| P: 1| L003|Single indentation uses a number of spaces not a multiple of 4
L:1| P: 14| L006 | Operators should be surrounded by a single space unless at the start/end of a line
L: 1| P: 27| L001|Unnecessary trailing whitespace
L: 1| P: 1| LT01|Expected only single space before 'SELECT' keyword.
| Found ' '. [layout.spacing]
L: 1| P: 1| LT02|First line should not be indented.
|[layout.indent]
L: 1| P: 1| LT13 | Files must not begin with newlines or whitespace.
|[layout.start_of_file]
L: 1| P: 11| LT01 | Expected only single space before binary operator '+'.
| Found ' '. [layout.spacing]
L: 1| P: 14| LT01 | Expected only single space before naked identifier.
| Found ' '. [layout.spacing]
L: 1| P: 27| LT01 | Unnecessary trailing whitespace at end of file.
|[layout.spacing]
L: 1| P: 27| LT12 | Files must end with a single trailing newline.
|[layout.end_of_file]
All Finished 📜 🎉!
```
You can also have a play using [**SQLFluff online**](https://online.sqlfluff.com/).
Alternatively, you can use the [**Official SQLFluff Docker Image**](https://hub.docker.com/r/sqlfluff/sqlfluff)
or have a play using [**SQLFluff online**](https://online.sqlfluff.com/).
For full [CLI usage](https://docs.sqlfluff.com/en/stable/cli.html) and [rules reference](https://docs.sqlfluff.com/en/stable/rules.html), see [the SQLFluff docs](https://docs.sqlfluff.com/en/stable/).
For full [CLI usage](https://docs.sqlfluff.com/en/stable/perma/cli.html) and
[rules reference](https://docs.sqlfluff.com/en/stable/perma/rules.html), see
For full documentation visit [docs.sqlfluff.com](https://docs.sqlfluff.com/en/stable/). This documentation is generated from this repository so please raise [issues](https://github.com/sqlfluff/sqlfluff/issues) or pull requests for any additions, corrections, or clarifications.
For full documentation visit [docs.sqlfluff.com](https://docs.sqlfluff.com/en/stable/).
This documentation is generated from this repository so please raise
[issues](https://github.com/sqlfluff/sqlfluff/issues) or pull requests
for any additions, corrections, or clarifications.
# Releases
**SQLFluff**is in beta phase - expect the tool to change significantly with potentially non-backwards compatible API and configuration changes in future releases. If you would like to join in please consider [contributing](CONTRIBUTING.md).
**SQLFluff**adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html),
so breaking changes should be restricted to major versions releases. Some
elements (such as the python API) are in a less stable state and may see more
significant changes more often. For details on breaking changes and how
to migrate between versions, see our
[release notes](https://docs.sqlfluff.com/en/latest/perma/releasenotes.html). See the
[changelog](CHANGELOG.md) for more details. If you would like to join in, please
consider [contributing](CONTRIBUTING.md).
New releases are made monthly. For more information, visit [Releases](https://github.com/sqlfluff/sqlfluff/releases).
New releases are made monthly. For more information, visit
Follow us [on Twitter @SQLFluff](https://twitter.com/SQLFluff) for announcements and other related posts.
Follow us [on Twitter @SQLFluff](https://twitter.com/SQLFluff) for announcements
and other related posts.
# Contributing
We are grateful to all our [contributors](https://github.com/sqlfluff/sqlfluff/graphs/contributors). There is a lot to do in this project, and we are just getting started.
We are grateful to all our [contributors](https://github.com/sqlfluff/sqlfluff/graphs/contributors).
There is a lot to do in this project, and we are just getting started.
If you want to understand more about the architecture of **SQLFluff**, you can find [more here](https://docs.sqlfluff.com/en/latest/architecture.html).
If you want to understand more about the architecture of **SQLFluff**, you can
If you would like to contribute, check out the [open issues on GitHub](https://github.com/sqlfluff/sqlfluff/issues). You can also see the guide to [contributing](CONTRIBUTING.md).
If you would like to contribute, check out the
[open issues on GitHub](https://github.com/sqlfluff/sqlfluff/issues). You can also see
We have a fast-growing `community on Slack <https://join.slack.com/t/sqlfluff/shared_invite/zt-o1f4x0e8-pZzarAIlQmKj_6ZwD16w0g>`_, come and join us!
We have a fast-growing `community on Slack <https://join.slack.com/t/sqlfluff/shared_invite/zt-2qtu36kdt-OS4iONPbQ3aCz2DIbYJdWg>`_, come and join us!
SQLFluff on Twitter
====================
Follow us On Twitter `@SQLFluff <https://twitter.com/SQLFluff>`_ for annoncements and other related posts.
Follow us On Twitter `@SQLFluff <https://twitter.com/SQLFluff>`_ for announcements and other related posts.
Some files were not shown because too many files have changed in this diff
Show More
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.