forked from sqlfluff/sqlfluff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LT08.yml
269 lines (216 loc) · 4.37 KB
/
LT08.yml
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
rule: LT08
test_pass_blank_line_after_cte_trailing_comma:
# Test cases for LT08, both leading and trailing commas.
pass_str: |
with my_cte as (
select 1
),
other_cte as (
select 1
)
select * from my_cte cross join other_cte
test_pass_blank_line_after_cte_leading_comma:
pass_str: |
with my_cte as (
select 1
)
, other_cte as (
select 1
)
select * from my_cte cross join other_cte
test_fail_no_blank_line_after_each_cte:
fail_str: |
with my_cte as (
select 1
),
other_cte as (
select 1
)
select * from my_cte cross join other_cte
fix_str: |
with my_cte as (
select 1
),
other_cte as (
select 1
)
select * from my_cte cross join other_cte
test_fail_no_blank_line_after_cte_before_comment:
fail_str: |
with my_cte as (
select 1
),
-- Comment
other_cte as (
select 1
)
select * from my_cte cross join other_cte
fix_str: |
with my_cte as (
select 1
),
-- Comment
other_cte as (
select 1
)
select * from my_cte cross join other_cte
test_fail_no_blank_line_after_cte_and_comment:
# Issue #2136
fail_str: |
WITH mycte AS (
SELECT col
FROM
my_table
) /* cte comment */
SELECT col
FROM
mycte
fix_str: |
WITH mycte AS (
SELECT col
FROM
my_table
) /* cte comment */
SELECT col
FROM
mycte
test_fail_no_blank_line_after_last_cte_trailing_comma:
fail_str: |
with my_cte as (
select 1
),
other_cte as (
select 1
)
select * from my_cte cross join other_cte
fix_str: |
with my_cte as (
select 1
),
other_cte as (
select 1
)
select * from my_cte cross join other_cte
test_fail_no_blank_line_after_last_cte_leading_comma:
fail_str: |
with my_cte as (
select 1
)
, other_cte as (
select 1
)
select * from my_cte cross join other_cte
fix_str: |
with my_cte as (
select 1
)
, other_cte as (
select 1
)
select * from my_cte cross join other_cte
test_fail_oneline_cte_leading_comma:
# Fixes oneline cte with leading comma style
fail_str: |
with my_cte as (select 1), other_cte as (select 1) select * from my_cte
cross join other_cte
fix_str: |
with my_cte as (select 1)
, other_cte as (select 1)
select * from my_cte
cross join other_cte
# NOTE: we're using the global comma position config
configs:
layout:
type:
comma:
line_position: leading
test_fail_cte_floating_comma:
# Fixes cte with a floating comma
fail_str: |
with my_cte as (select 1)
,
other_cte as (select 1)
select * from my_cte cross join other_cte
fix_str: |
with my_cte as (select 1)
,
other_cte as (select 1)
select * from my_cte cross join other_cte
test_pass_column_name_definition:
# Issue #2136
pass_str: |
with recursive t(n) as (
select 1
union all
select n + 1 from t
)
select n from t limit 100;
test_pass_column_name_definition_multiple:
# Issue #3474
pass_str: |
WITH
cte_1 AS (
SELECT 1 AS var
),
cte_2 (var) AS (
SELECT 2
)
SELECT
cte_1.var,
cte_2.var
FROM cte_1, cte_2;
test_fail_column_name_definition_newline:
fail_str: |
WITH
cte_1 (var) AS
(
SELECT 2
)
SELECT
cte_1.var,
cte_2.var
FROM cte_1, cte_2;
fix_str: |
WITH
cte_1 (var) AS
(
SELECT 2
)
SELECT
cte_1.var,
cte_2.var
FROM cte_1, cte_2;
test_fail_column_name_definition_comment:
fail_str: |
WITH
cte_1 (var) AS /* random comment */ (
SELECT 2
)
SELECT
cte_1.var,
cte_2.var
FROM cte_1, cte_2;
fix_str: |
WITH
cte_1 (var) AS /* random comment */ (
SELECT 2
)
SELECT
cte_1.var,
cte_2.var
FROM cte_1, cte_2;
test_pass_recursive_with_argument_list:
pass_str: |
WITH RECURSIVE my_cte (n) AS (
select 1
)
select * from my_cte
test_pass_recursive_with_argument_list_postgres:
pass_str: |
WITH RECURSIVE my_cte (n) AS (
select 1
)
select * from my_cte
configs:
core:
dialect: postgres