Add fix routine for L025
See original GitHub issueThis query has two problems:
$ echo 'select * from (select 1 as a) subquery' | sqlfluff lint -
== [stdin] FAIL
L: 1 | P: 31 | L011 | Implicit aliasing of table not allowed. Use explicit
| `AS` clause.
L: 1 | P: 31 | L025 | Alias 'subquery' is never used in SELECT statement.
It gets fixed as such
$ echo 'select * from (select 1 as a) subquery' | sqlfluff fix - --rules L011,L010,L025
select * from (select 1 as a) as subquery
But if you lint the fixed sql, L025 remains!
$ echo 'select * from (select 1 as a) subquery' | sqlfluff fix - --rules L011,L010,L025 | sqlfluff lint -
== [stdin] FAIL
L: 1 | P: 34 | L025 | Alias 'subquery' is never used in SELECT statement.
The conjunction of these two errors shows that the “real” fix would be this query
$ echo 'select * from (select 1 as a)' | sqlfluff lint -
# no violations!
Should fluff remove the implicit alias if it is never used?
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (12 by maintainers)
Top Results From Across the Web
sqlfluff/CHANGELOG.md at main - GitHub
Adding AWS Athena as a dialect. A fix routine for L046 (whitespace in jinja tags), and the mechanisms for more source-only fixes in...
Read more >sqlfluff 0.5.4 - PyPI
To get started, install the package and run sqlfluff lint or sqlfluff fix . $ pip install sqlfluff $ echo " SELECT ......
Read more >L025 Scarlet Pleco (Wild-Caught) - Pet Zone Tropical Fish
Find the L-25 Scarlet Pleco for sale at PetZoneSD.com. One of the rarest plecos in the fish keeping hobby!
Read more >sqlfluff Changelog - pyup.io
Add source fixing capability and fix routines for L046 ... Groundwork for a fix routine for L046 ... Fix L025 false positive for...
Read more >Two Nifty Programs
Note: set display to fix 4 for angles but be realistic about your distance precisions! ... your RPN adding machine into a 400...
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
As it turns out, the example query and fix is invalid syntax in every database I tested (MySQL, Postgres, T-SQL). Basically, “derived queries” require an alias. See issue #3545. For that issue, I’m adding an exception to the rule, so derived table aliases will never be removed, whether they are used or not.
That’s really nice of you! I’ll take you up on it when i get some more bandwidth