-
Notifications
You must be signed in to change notification settings - Fork 3
SQLFluff #25
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
base: main
Are you sure you want to change the base?
SQLFluff #25
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
[sqlfluff] | ||
dialect = ansi | ||
templater = jinja | ||
exclude_rules = L009 # trailing comma enforcement skipped | ||
format = json | ||
nocolor = True | ||
|
||
[sqlfluff:rules] | ||
max_line_length = 100 | ||
tab_space_size = 4 | ||
|
||
[sqlfluff:rules:L010] # Keywords | ||
capitalisation_policy = upper | ||
|
||
[sqlfluff:rules:L014] # Unquoted identifiers | ||
extended_capitalisation_policy = consistent | ||
|
||
[sqlfluff:rules:L016] # Line length | ||
max_line_length = 100 | ||
|
||
[sqlfluff:rules:L019] # Leading comma check | ||
comma_style = trailing | ||
|
||
[sqlfluff:rules:L030] # Function names | ||
capitalisation_policy = lower | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,19 @@ | ||||||||||||||||||||||||||
SELECT id,Name , age FROM users WHERE age>25 order BY name; | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. First query violates almost every configured rule – re-format or mark as an intentional anti-example Unless you purposely keep this broken for demo purposes, tidy it: -SELECT id,Name , age FROM users WHERE age>25 order BY name;
+SELECT
+ id,
+ name,
+ age
+FROM users
+WHERE age > 25
+ORDER BY name; 🧰 Tools🪛 SQLFluff (3.4.1)1-1: Select targets should be on a new line unless there is only one select target. 1-1: Expected only single space before naked identifier. Found ' '. 1-1: Unquoted identifiers must be consistently lower case. 1-1: Expected single whitespace between comma ',' and naked identifier. 1-1: Unexpected whitespace before comma ','. 1-1: Expected only single space before naked identifier. Found ' '. 1-1: The 'WHERE' keyword should always start a new line. 1-1: Expected single whitespace between naked identifier and raw comparison operator '>'. 1-1: Expected single whitespace between raw comparison operator '>' and numeric literal. 1-1: Keywords must be consistently upper case. 1-1: The 'order' keyword should always start a new line. 🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
SELECT select, from, where FROM keywords; | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reserved words used as column names – quote or rename
-SELECT select, from, where FROM keywords;
+SELECT "select", "from", "where"
+FROM keywords; 🧰 Tools🪛 SQLFluff (3.4.1)3-3: Expected line break and indent of 4 spaces before 'select'. 3-3: Line 3, Position 8: Found unparsable section: 'select' 3-3: Trailing comma in select statement forbidden 3-3: Line 3, Position 16: Found unparsable section: 'from, where FROM keywords' 🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
SELECT | ||||||||||||||||||||||||||
id | ||||||||||||||||||||||||||
name | ||||||||||||||||||||||||||
FROM customers; | ||||||||||||||||||||||||||
Comment on lines
+5
to
+9
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Missing commas & mis-indentation break the multi-line SELECT Add commas and follow the 4-space indent policy: -SELECT
- id
- name
- email
-FROM customers;
+SELECT
+ id,
+ name,
+ email
+FROM customers; 📝 Committable suggestion
Suggested change
🧰 Tools🪛 SQLFluff (3.4.1)5-5: Expected indent of 4 spaces. 6-6: Expected indent of 8 spaces. 7-7: Expected indent of 12 spaces. 7-7: Implicit/explicit aliasing of columns. 7-7: Keywords should not be used as identifiers. 8-8: Line 8, Position 5: Found unparsable section: 'email' 9-9: Expected indent of 4 spaces. 9-9: Expected only single space before naked identifier. Found ' '. 🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
SELECT u.id, o.order_id, o.amount FROM users u | ||||||||||||||||||||||||||
JOIN orders o | ||||||||||||||||||||||||||
on u.id = o.user_id | ||||||||||||||||||||||||||
WHERE o.amount>1000; | ||||||||||||||||||||||||||
Comment on lines
+11
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. JOIN block needs consistent casing, aliased tables, and spacing -SELECT u.id, o.order_id, o.amount FROM users u
-JOIN orders o
-on u.id = o.user_id
-WHERE o.amount>1000;
+SELECT
+ u.id,
+ o.order_id,
+ o.amount
+FROM users AS u
+INNER JOIN orders AS o
+ ON u.id = o.user_id
+WHERE o.amount > 1000; 📝 Committable suggestion
Suggested change
🧰 Tools🪛 SQLFluff (3.4.1)11-11: Expected indent of 4 spaces. 11-11: Select targets should be on a new line unless there is only one select target. 11-11: Implicit/explicit aliasing of table. 12-12: Join clauses should be fully qualified. 12-12: Expected indent of 4 spaces. 12-12: Implicit/explicit aliasing of table. 13-13: Keywords must be consistently upper case. 13-13: Expected indent of 8 spaces. 14-14: Expected indent of 8 spaces. 14-14: Expected single whitespace between naked identifier and raw comparison operator '>'. 14-14: Expected single whitespace between raw comparison operator '>' and numeric literal. 🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
SELECT a.id, b.value | ||||||||||||||||||||||||||
FROM table1 a, table2 b | ||||||||||||||||||||||||||
WHERE a.id = b.id; | ||||||||||||||||||||||||||
|
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.
💡 Verification agent
🧩 Analysis chain
Potential rule conflict – double-check the intent behind disabling L009 while keeping L019 active
You disable
L009
(“trailing comma enforcement”) but immediately configureL019
forcomma_style = trailing
. If you actually want trailing commas enforced, dropL009
fromexclude_rules
; if not, remove or change thecomma_style
entry so the two settings don’t contradict each other.Example quick fix:
🏁 Script executed:
Length of output: 135
Align SQLFluff comma rules
You’ve turned off L009 but left
comma_style = trailing
for L019—those settings fight each other. Decide whether you want trailing commas or not and update both accordingly:•
.sqlfluff
, line 4 – adjust yourexclude_rules
•
.sqlfluff
, line 22 – update or remove thecomma_style
settingExample fixes:
If you want to enforce trailing commas:
If you don’t want trailing commas:
🤖 Prompt for AI Agents