* 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 7a231b7ff8.
* 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 b5df02bf8f.
* 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 c9c81fc0ca.
* 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 4198e559e7.
- 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 1252d41f09.
* 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 2c39e4256d.
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 fdb9cdfb19.
* 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 d7137101d8.
* 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>
2022-02-16 16:45:53 +00:00
4849 changed files with 408358 additions and 114152 deletions
- When developing on some more complicated rules, or ones known to
have interactions with other rules, there are a set of rule fixing
tests which apply a set combination of those rules. These are best
run via the `autofix` tests. For example:
-`tox -e py39 -- test/rules/std_fix_auto_test.py`
-`pytest test/rules/std_fix_auto_test.py`
- Potentially even the full rules suite `tox -e py39 -- test/rules`
- A small number of core rules are also used in making sure that inner
parts of SQLFluff are also functioning. This isn't great isolation
but does mean that occasionally you may find side effects of your
changes in the wider test suite. These can usually be caught by
running the full `tox -e py39` suite as a final check (or using the
test suite on GitHub when posting your PR).
4. When developing the internals of SQLFluff (i.e. anything not
already mentioned above), the test suite typically mirrors the structure
of the internal submodules of sqlfluff:
- When working with the CLI, the `sqlfluff.cli` module has a test suite
called via `tox -e py39 -- test/cli`.
- When working with the templaters (i.e. `sqlfluff.core.templaters`), the
corresponding test suite is found via `tox -e py39 -- test/core/templaters`.
- This rough guidance and may however not apply for all of the internals.
For example, changes to the internals of the parsing module (`sqlfluff.core.parser`)
are very likely to have knock-on implications across the rest of the test
suite and it may be necessary to run the whole thing. In these
situations however you can usually work slowly outward, for example:
1. If your change is to the `AnyOf()` grammar, first running `tox -e py39 -- test/core/parser/grammar_test.py` would be wise.
2. ...followed by `tox -e py39 -- test/core/parser` once the above is passing.
3. ...and then `tox -e py39 -- test/core`.
4. ...and finally the full suite `tox -e py39`.
#### dbt templater tests
The dbt templater tests require a locally running Postgres instance. See the required connection parameters in `plugins/sqlfluff-templater-dbt/test/fixtures/dbt/profiles.yml`. We recommend using https://postgresapp.com/.
The dbt templater tests require a locally running Postgres instance. See the
required connection parameters in `plugins/sqlfluff-templater-dbt/test/fixtures/dbt/profiles.yml`.
We recommend using https://postgresapp.com/.
To run the dbt-related tests you will have to explicitly include these tests:
* 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.
* Manually edit the `host` value in `plugins/sqlfluff-templater-dbt/test/fixtures/dbt/profiles_yml/profiles.yml`, changing it to `postgres`. (This will likely be automated somehow in the future.)
* Run `plugins/sqlfluff-templater-dbt/docker/shell` to start a bash session
For development convenience we also provide a `.pre-commit-config.yaml` file to allow the user to install a selection of pre-commit hooks via `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.
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
@@ -224,26 +306,81 @@ whenever a new release is published to GitHub.
#### Release checklist:
The [release page](https://github.com/sqlfluff/sqlfluff/releases) shows maintainers all merges since last release. Once we have a long enough list, we should prepare a release, following below checklist:
The [release page](https://github.com/sqlfluff/sqlfluff/releases) shows
maintainers all merges since last release. Once we have a long enough list,
we should prepare a release.
- [ ] Change the version in `setup.cfg` and `plugins/sqlfluff-templator-dbt/setup.cfg`
A release PR can be created by maintainers via the
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 ([an issues](https://github.com/release-drafter/release-drafter/issues/1001) has been raised to ask for this in Release Drafter GitHub Action).
- [ ] Add markdown links to PRs as annoyingly GitHub doesn't do this automatically when displaying Markdown files, like it does for comments. You can use regex in most code editors to replace `\(#([0-9]*)\) @([^ ]*)$` to `[#$1](https://github.com/sqlfluff/sqlfluff/pull/$1) [@$2](https://github.com/$2)`, or if using the GitHub generated release notes then can replace `by @([^ ]*) in https://github.com/sqlfluff/sqlfluff/pull/([0-9]*)$` to `[#$2](https://github.com/sqlfluff/sqlfluff/pull/$2) [@$1](https://github.com/$1)`.
- [ ]For the new contributors section, you can replace `\* @([^ ]*) made their first contribution in https://github.com/sqlfluff/sqlfluff/pull/([0-9]*)$` with `* [@$1](https://github.com/$1) made their first contribution in [#$2](https://github.com/sqlfluff/sqlfluff/pull/$2)` to do this automatically).
- [ ] Check each issue title is clear, and if not edit issue title (which will automatically update Release notes on next PR merged, as the Draft one is recreated in full each time). We also don't use [conventional commit PR titles](https://www.conventionalcommits.org/en/v1.0.0/) (e.g. `feat`) so make them more English readible. Make same edits locally in [CHANGELOG.md](CHANGELOG.md).
- [ ] Copy the draft releases from https://github.com/sqlfluff/sqlfluff/releases
to [CHANGELOG.md](CHANGELOG.md). Thesedraftrelease 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
(e.g. `feat`) so make them more English readable. Make same edits locally
in [CHANGELOG.md](CHANGELOG.md).
- [ ] Add a comment at the top to highlight the main things in this release.
- [ ] If this is a non-patch release then update the `Notable changes` section in`index.rst` with a brief summary of the new features added that made this a non-patch release.
- [ ] View the CHANGELOG in this branch on GitHub to ensure you didn't miss any link conversions or other markup errors.
- [ ] Open draft PR with those change a few days in advance to give contributors notice. Tag those with open PRs in the PR in GitHub to give them time to merge their work before the new release
- [ ] If this is a non-patch release then update the `Notable changes` section in
`index.rst` with a brief summary of the new features added that made this a
non-patch release.
- [ ] View the CHANGELOG in this branch on GitHub to ensure you didn't miss any
link conversions or other markup errors.
- [ ] Open draft PR with those change a few days in advance to give contributors
notice. Tag those with open PRs in the PR in GitHub to give them time to merge
their work before the new release
- [ ] Comment in #contributing slack channel about release candidate.
- [ ] Update the draft PR as more changes get merged.
- [ ] Get another contributor to approve the PR.
- [ ] Merge the PR when looks like we've got all we’re gonna get for this release.
- [ ] Go to the [releases page](https://github.com/sqlfluff/sqlfluff/releases), edit the release to be same as [CHANGELOG.md](CHANGELOG.md) (remember to remove your release PR which doesn’t need to go in this). Add version tag and a title and click “Publish release”.
- [ ] Announce the release in the #general channel, with shout outs to those who contributed many, or big items.
- [ ] Announce the release on Twitter (@tunetheweb can do this or let him know your Twitter handle if you want access to Tweet on SQLFluff’s behalf).
- [ ] Merge the PR when looks like we've got all we’re going to get for this release.
- [ ] Go to the [releases page](https://github.com/sqlfluff/sqlfluff/releases), edit
the release to be same as [CHANGELOG.md](CHANGELOG.md) (remember to remove your
release PR which doesn’t need to go in this). Add version tag and a title and
click “Publish release”.
- [ ] Announce the release in the #general channel, with shout outs to those who
contributed many, or big items.
- [ ] Announce the release on Twitter (@tunetheweb can do this or let him know your
Twitter handle if you want access to Tweet on SQLFluff’s behalf).
:warning: **Before creating a new release, ensure that
[setup.cfg](setup.cfg) is up-to-date with a new version** :warning:.
**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`.
@@ -54,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 📜 🎉!
```
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/).
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
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.