question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add fix routine for L025

See original GitHub issue

This 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:closed
  • Created 3 years ago
  • Comments:12 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
barrywhartcommented, Jul 2, 2022

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.

1reaction
nolanbconawaycommented, Feb 10, 2021

Great! If you’re interested some time, I’d be happy to schedule an hour to pair program on an issue (Zoom screen share or something like that). Maybe that could be step 1 towards the “new contributor” docs you suggested. If you’re interested, ping me on Slack and we’ll set something up.

That’s really nice of you! I’ll take you up on it when i get some more bandwidth

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found