New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent exceptions when running fix
on dialect fixtures
#2818
Prevent exceptions when running fix
on dialect fixtures
#2818
Conversation
Codecov Report
@@ Coverage Diff @@
## main #2818 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 163 163
Lines 12322 12326 +4
=========================================
+ Hits 12322 12326 +4
Continue to review full report at Codecov.
|
fix
on dialect fixtures
can we add test cases for the things it fixes? |
Yeah probably should. This started out as one simple fix, but growing legs as I scan the rest of the dialect fixtures. Will start to add some test cases. |
Added where possible. Through two I couldn't get to work under pytest. |
@@ -802,28 +802,32 @@ def _choose_anchor_segment( | |||
|
|||
anchor: BaseSegment = segment | |||
child: BaseSegment = segment | |||
for seg in context.parent_stack[0].path_to(segment)[1:-1][::-1]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert len(table_aliases) > 0, "Only Selects with tables should be checked" | ||
if len(table_aliases) > 1: | ||
if len(table_aliases) != 1: | ||
return None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't see why we abort on more than one, but not on 0? Same thing IMHO and this fixes one of the issues raised.
This should be good to go now. Includes the See note about, about timing though :-( But only a minute or so slower and I think worth it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! I asked about whether/when we want to do the sqlfluff fix
test using other .sqlfluff
configurations. (Danny's configuration seemed to produce a lot more errors than the default.)
for DIALECT in "${DIALECTS[@]}" | ||
do | ||
echo "Testing $DIALECT SQL files fix without critical errors..." | ||
OUTPUT=$(sqlfluff fix -f ${DIALECT}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interested in adding other .sqlfluff
files, e.g. Danny's from #2811? (Feel free to create a ticket for later.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's already the longest running job so would suggest a separate, parallel, job if we do that.
However I did test it with tab_space = 2
and got no CRITICAL errors (which is all it currently looks for) any more since your fix, plus the ones here.
Are you still getting the errors if you do it on this branch? Cause if not, then no need to add. The default config identified the issues and they were fixed.
Brief summary of the change made
Fixes #2817 with simple additional safeguard test.
Fixes #2812
Also adds a few more I've found in similar cases.
And updates our CI to test
fix
instead oflint
against dialect fixtures (notfix
does alint
as part of that solint
is still tested), to prevent similar future issues.Are there any other side effects of this change that we should be aware of?
The
fix
tests take longer to run, finishing just after windows tests (which was previous slowest test) so CI does slow down a couple of mins :-(Pull Request checklist
Please confirm you have completed any of the necessary steps below.
Included test cases to demonstrate any code changes, which may be one or more of the following:
.yml
rule test cases intest/fixtures/rules/std_rule_cases
..sql
/.yml
parser test cases intest/fixtures/dialects
(note YML files can be auto generated withtox -e generate-fixture-yml
).test/fixtures/linter/autofix
.Added appropriate documentation for the change.
Created GitHub issues for any relevant followup/future enhancements if appropriate.