forked from sqlfluff/sqlfluff
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLT14.yml
More file actions
518 lines (486 loc) · 9.43 KB
/
Copy pathLT14.yml
File metadata and controls
518 lines (486 loc) · 9.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
rule: LT14
test_pass_leading_from_clause:
pass_str: |
SELECT foo
FROM bar
configs:
layout:
type:
from_clause:
keyword_line_position: leading
test_pass_alone_from_clause:
pass_str: |
SELECT foo
FROM
bar
configs:
layout:
type:
from_clause:
keyword_line_position: alone
test_fail_leading_from_clause:
fail_str: |
SELECT foo FROM bar
fix_str: |
SELECT foo
FROM bar
configs:
layout:
type:
from_clause:
keyword_line_position: leading
test_fail_alone_from_clause:
fail_str: |
SELECT foo FROM bar
fix_str: |
SELECT foo
FROM
bar
configs:
layout:
type:
from_clause:
keyword_line_position: alone
test_pass_leading_join_clause:
pass_str: |
SELECT foo
FROM bar a
JOIN baz b
ON a.id = b.id
INNER JOIN qux c
ON a.id = c.id
LEFT OUTER JOIN quux d
ON a.id = d.id
configs:
layout:
type:
join_clause:
keyword_line_position: leading
test_fail_leading_join_clause:
fail_str: |
SELECT foo
FROM bar a JOIN baz b
ON a.id = b.id INNER JOIN qux c
ON a.id = c.id LEFT OUTER JOIN quux d
ON a.id = d.id
fix_str: |
SELECT foo
FROM bar a
JOIN baz b
ON a.id = b.id
INNER JOIN qux c
ON a.id = c.id
LEFT OUTER JOIN quux d
ON a.id = d.id
configs:
layout:
type:
join_clause:
keyword_line_position: leading
test_pass_alone_join_clause:
pass_str: |
SELECT foo
FROM bar a
JOIN
baz b
ON a.id = b.id
configs:
layout:
type:
join_clause:
keyword_line_position: alone
test_fail_alone_join_clause:
fail_str: |
SELECT foo
FROM bar a JOIN baz b
ON a.id = b.id INNER JOIN qux c
ON a.id = c.id LEFT OUTER JOIN quux d
ON a.id = d.id
fix_str: |
SELECT foo
FROM bar a
JOIN
baz b
ON a.id = b.id
INNER JOIN
qux c
ON a.id = c.id
LEFT OUTER JOIN
quux d
ON a.id = d.id
configs:
layout:
type:
join_clause:
keyword_line_position: alone
test_pass_leading_join_clause_on_condition:
pass_str: |
SELECT foo
FROM bar a
JOIN baz b
ON a.id = b.id
configs:
layout:
type:
join_clause:
keyword_line_position: leading
join_on_condition:
keyword_line_position: leading
test_fail_leading_join_clause_on_condition:
fail_str: |
SELECT foo
FROM bar a JOIN baz b ON a.id = b.id
fix_str: |
SELECT foo
FROM bar a
JOIN baz b
ON a.id = b.id
configs:
layout:
type:
join_clause:
keyword_line_position: leading
join_on_condition:
keyword_line_position: leading
test_pass_alone_join_clause_on_condition:
pass_str: |
SELECT foo
FROM bar a
JOIN
baz b
ON
a.id = b.id
configs:
layout:
type:
join_clause:
keyword_line_position: alone
join_on_condition:
keyword_line_position: alone
test_pass_leading_join_clause_trailing_on_condition:
pass_str: |
SELECT foo
FROM bar a
JOIN baz b ON
a.id = b.id
configs:
layout:
type:
join_clause:
keyword_line_position: leading
join_on_condition:
keyword_line_position: trailing
test_fail_leading_join_clause_trailing_on_condition:
fail_str: |
SELECT foo
FROM bar a JOIN baz b ON a.id = b.id
fix_str: |
SELECT foo
FROM bar a
JOIN baz b ON
a.id = b.id
configs:
layout:
type:
join_clause:
keyword_line_position: leading
join_on_condition:
keyword_line_position: trailing
test_fail_alone_join_clause_on_condition:
fail_str: |
SELECT foo
FROM bar a
JOIN baz b
ON a.id = b.id
fix_str: |
SELECT foo
FROM bar a
JOIN
baz b
ON
a.id = b.id
configs:
layout:
type:
join_clause:
keyword_line_position: alone
join_on_condition:
keyword_line_position: alone
test_pass_leading_window_function:
pass_str: |
SELECT
a,
b,
ROW_NUMBER() OVER (
PARTITION BY c
ORDER BY d
) AS e
FROM f
JOIN g
ON g.h = f.h
configs:
layout:
type:
partitionby_clause:
keyword_line_position: leading
orderby_clause:
keyword_line_position: leading
test_pass_leading_window_comment_function:
pass_str: |
SELECT
a,
b,
ROW_NUMBER() OVER ( /* comment here */
PARTITION BY c
ORDER BY d
) AS e
FROM f
JOIN g
ON g.h = f.h
configs:
layout:
type:
partitionby_clause:
keyword_line_position: leading
orderby_clause:
keyword_line_position: leading
test_fail_leading_window_function:
fail_str: |
SELECT
a,
b,
ROW_NUMBER() OVER (PARTITION BY c ORDER BY d) AS e
FROM f
JOIN g
ON g.h = f.h
fix_str: |
SELECT
a,
b,
ROW_NUMBER() OVER (
PARTITION BY c
ORDER BY d) AS e
FROM f
JOIN g
ON g.h = f.h
configs:
layout:
type:
partitionby_clause:
keyword_line_position: leading
orderby_clause:
keyword_line_position: leading
test_pass_alone_window_function:
pass_str: |
SELECT
a,
b,
ROW_NUMBER() OVER (
PARTITION BY
c
ORDER BY
d
) AS e
FROM f
JOIN g
ON g.h = f.h
configs:
layout:
type:
partitionby_clause:
keyword_line_position: alone
orderby_clause:
keyword_line_position: alone
test_fail_alone_window_function:
fail_str: |
SELECT
a,
b,
ROW_NUMBER() OVER (PARTITION BY c ORDER BY d) AS e
FROM f
JOIN g
ON g.h = f.h
fix_str: |
SELECT
a,
b,
ROW_NUMBER() OVER (
PARTITION BY
c
ORDER BY
d) AS e
FROM f
JOIN g
ON g.h = f.h
configs:
layout:
type:
partitionby_clause:
keyword_line_position: alone
orderby_clause:
keyword_line_position: alone
test_pass_leading_qualify:
pass_str: |
SELECT
a,
b
FROM f
JOIN g
ON g.h = f.h
QUALIFY ROW_NUMBER() OVER (PARTITION BY c
ORDER BY d) = 1
configs:
core:
dialect: duckdb
layout:
type:
qualify_clause:
keyword_line_position: leading
test_pass_alone_qualify:
pass_str: |
SELECT
a,
b
FROM f
JOIN g
ON g.h = f.h
QUALIFY
ROW_NUMBER() OVER (PARTITION BY c
ORDER BY d) = 1
configs:
core:
dialect: duckdb
layout:
type:
qualify_clause:
keyword_line_position: alone
test_fail_leading_qualify:
fail_str: |
SELECT
a,
b
FROM f
JOIN g
ON g.h = f.h QUALIFY ROW_NUMBER() OVER (PARTITION BY c ORDER BY d) = 1
fix_str: |
SELECT
a,
b
FROM f
JOIN g
ON g.h = f.h
QUALIFY ROW_NUMBER() OVER (PARTITION BY c
ORDER BY d) = 1
configs:
core:
dialect: duckdb
layout:
type:
qualify_clause:
keyword_line_position: leading
test_fail_alone_qualify:
fail_str: |
SELECT
a,
b
FROM f
JOIN g
ON g.h = f.h
QUALIFY ROW_NUMBER() OVER (PARTITION BY c
ORDER BY d) = 1
fix_str: |
SELECT
a,
b
FROM f
JOIN g
ON g.h = f.h
QUALIFY
ROW_NUMBER() OVER (PARTITION BY c
ORDER BY d) = 1
configs:
core:
dialect: duckdb
layout:
type:
qualify_clause:
keyword_line_position: alone
test_fail_cte_selects_3419:
fail_str: |
WITH some_cte AS (SELECT
column1,
column2
FROM some_table
) SELECT
column1,
column2
FROM some_cte
fix_str: |
WITH some_cte AS (
SELECT
column1,
column2
FROM some_table
)
SELECT
column1,
column2
FROM some_cte
configs:
layout:
type:
select_clause:
keyword_line_position: alone
test_fail_all_keyword_segment:
# This is a bit strange, but handles for a case where the
# segment is all keywords.
fail_str: |
CREATE TABLE t (c1 DOUBLE PRECISION NOT NULL)
fix_str: |
CREATE TABLE t (c1
DOUBLE PRECISION
NOT NULL)
configs:
layout:
type:
data_type:
keyword_line_position: alone
test_pass_leading_non_indent_first_segment:
# a window_specification doesn't have a leading keyword,
# this rule should have no effect on it. For now.
pass_str: |
select a, sum(b) over (named_window partition by c) as sum_b
from t window named_window as (partition by e)
configs:
layout:
type:
window_specification:
keyword_line_position: leading
test_pass_templated_leading_from_clause:
pass_str: |
{% macro join_type(expression) %}
{{ expression }}
{% endmacro %}
SELECT a.foo, b.bar FROM baz a
{{ join_type("LEFT") }} JOIN tab b
ON a.col = b.col
configs:
layout:
type:
join_clause:
keyword_line_position: alone
test_pass_none_where_clause:
pass_str: |
SELECT a, b FROM tabx WHERE b = 2;
configs:
layout:
type:
where_clause:
keyword_line_position: none
test_pass_single_line_set:
# A single line set expression should be possible without forcing a newline.
pass_str: |
SET increment_key = (SELECT MAX(COALESCE(date_key, '2021-01-01') - 1) AS increment_key FROM foo.bar);
configs:
core:
dialect: snowflake