Internal error on fixing L032
See original GitHub issueSearch before asking
- I searched the issues and found no similar issues.
What Happened
sqlfluff fix x.sql --dialect=mysql --rules=L032
causes internal error,
where x.sql has following contents:
select c1.Name, c2.Name, c5.Name from city as c1
inner join city as c2 using (ID)
inner join (
select c3.ID, c4.Name from city as c3
inner join city as c4 using (ID)
) as c5
on c1.ID = c5.ID
limit 3;
This is a valid query and works fine with the world database in MySQL Example Databases (https://dev.mysql.com/doc/index-other.html)
mysql> select c1.Name, c2.Name, c5.Name from city as c1
-> inner join city as c2 using (ID)
-> inner join (
-> select c3.ID, c4.Name from city as c3
-> inner join city as c4 using (ID)
-> ) as c5
-> on c1.ID = c5.ID
-> limit 3;
+----------+----------+----------+
| Name | Name | Name |
+----------+----------+----------+
| Kabul | Kabul | Kabul |
| Qandahar | Qandahar | Qandahar |
| Herat | Herat | Herat |
+----------+----------+----------+
3 rows in set (0.00 sec)
Expected Behaviour
success without internal error
Observed Behaviour
internal error occurred
(sqlfluff) ~/prog/python-study/sqlfluff% sqlfluff fix x.sql --dialect=mysql --rules=L032
==== finding fixable violations ====
WARNING SEG: (<CodeSegment: (None) 'c1'>, <SymbolSegment: (None) '.'>, <CodeSegment: (None) 'ID'>), POS: None
WARNING Unable to lint x.sql due to an internal error. Please report this as an issue with your query's contents and stacktrace below!
To hide this warning, add the failing file to .sqlfluffignore
Traceback (most recent call last):
File "/Users/yoichi/.virtualenvs/sqlfluff/lib/python3.10/site-packages/sqlfluff/core/linter/runner.py", line 103, in run
yield partial()
File "/Users/yoichi/.virtualenvs/sqlfluff/lib/python3.10/site-packages/sqlfluff/core/linter/linter.py", line 741, in lint_rendered
return cls.lint_parsed(
File "/Users/yoichi/.virtualenvs/sqlfluff/lib/python3.10/site-packages/sqlfluff/core/linter/linter.py", line 667, in lint_parsed
tree, initial_linting_errors, ignore_buff = cls.lint_fix_parsed(
File "/Users/yoichi/.virtualenvs/sqlfluff/lib/python3.10/site-packages/sqlfluff/core/linter/linter.py", line 586, in lint_fix_parsed
new_tree, _, _ = tree.apply_fixes(
File "/Users/yoichi/.virtualenvs/sqlfluff/lib/python3.10/site-packages/sqlfluff/core/parser/segments/base.py", line 1278, in apply_fixes
s, before, after = seg.apply_fixes(dialect, rule_code, fixes)
File "/Users/yoichi/.virtualenvs/sqlfluff/lib/python3.10/site-packages/sqlfluff/core/parser/segments/base.py", line 1278, in apply_fixes
s, before, after = seg.apply_fixes(dialect, rule_code, fixes)
File "/Users/yoichi/.virtualenvs/sqlfluff/lib/python3.10/site-packages/sqlfluff/core/parser/segments/base.py", line 1278, in apply_fixes
s, before, after = seg.apply_fixes(dialect, rule_code, fixes)
[Previous line repeated 3 more times]
File "/Users/yoichi/.virtualenvs/sqlfluff/lib/python3.10/site-packages/sqlfluff/core/parser/segments/base.py", line 1331, in apply_fixes
segments=self._position_segments(
File "/Users/yoichi/.virtualenvs/sqlfluff/lib/python3.10/site-packages/sqlfluff/core/parser/segments/base.py", line 549, in _position_segments
raise ValueError("Unable to find working position.")
ValueError: Unable to find working position.
==== no fixable linting violations found ====
All Finished 📜 🎉!
How to reproduce
sqlfluff fix x.sql --dialect=mysql --rules=L032
Dialect
MySQL
Version
sqlfluff, version 1.2.1 Python 3.10.0
Configuration
not using configuration file
Are you willing to work on and submit a PR to address the issue?
- Yes I am willing to submit a PR!
Code of Conduct
- I agree to follow this project’s Code of Conduct
Issue Analytics
- State:
- Created a year ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
BUG: Error on Lint SQL file Contains Custom Created-macros ...
the error showed up when I try to do sqlfluff lint on sql files which contains custom created-macros using dbt and bigquery WARNING...
Read more >Rules Reference — SQLFluff 1.4.5 documentation
This rule will fail if a single section of whitespace contains both tabs and spaces. This rule is sqlfluff fix compatible. Groups: all...
Read more >HOW TO FIX an internal error occurred in the initialisation ...
To help troubleshoot error messages and other issues, you can start Windows 7 by using a minimal set of drivers and startup programs....
Read more >sqlfluff 0.5.6 - PyPI
SQLFluff will auto-fix most linting errors, allowing you to focus your time on ... (#447); A limit in the internal fix routines to...
Read more >Electric Actuator / Rod Type LEY Series
When mounting styles are [Rod/Head flange] or ... LEY-L032. LEY-F032. LEY-D032. 32/40. LE-D-2-3 ... the space of an internal guide, and an increase....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Found a fairly simple solution, PR is live and ready for review.
ok, I think I know what’s going on here:
This should be solvable by passing the child at least a partially useful position to work with. I’ll work on a fix.