forked from sqlfluff/sqlfluff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ST06.yml
218 lines (197 loc) · 4.38 KB
/
ST06.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
rule: ST06
test_pass_select_statement_order:
pass_str: |
select
a,
cast(b as int) as b,
c
from x
test_fail_select_statement_order_1:
fail_str: |
select
a,
row_number() over (partition by id order by date) as y,
b
from x
line_numbers: [1]
fix_str: |
select
a,
b,
row_number() over (partition by id order by date) as y
from x
test_fail_select_statement_order_2:
fail_str: |
select
row_number() over (partition by id order by date) as y,
*,
cast(b as int) as b_int
from x
line_numbers: [1]
fix_str: |
select
*,
cast(b as int) as b_int,
row_number() over (partition by id order by date) as y
from x
test_fail_select_statement_order_3:
fail_str: |
select
row_number() over (partition by id order by date) as y,
cast(b as int) as b_int,
*
from x
line_numbers: [1]
fix_str: |
select
*,
cast(b as int) as b_int,
row_number() over (partition by id order by date) as y
from x
test_fail_select_statement_order_4:
fail_str: |
select
row_number() over (partition by id order by date) as y,
b::int,
*
from x
line_numbers: [1]
fix_str: |
select
*,
b::int,
row_number() over (partition by id order by date) as y
from x
test_fail_select_statement_order_5:
fail_str: |
select
row_number() over (partition by id order by date) as y,
*,
2::int + 4 as sum,
cast(b) as c
from x
line_numbers: [1]
fix_str: |
select
*,
cast(b) as c,
row_number() over (partition by id order by date) as y,
2::int + 4 as sum
from x
test_union_statements_ignored:
pass_str: |
select
a + b as c,
d
from table_a
union all
select
c,
d
from table_b
test_insert_statements_ignored:
pass_str: |
INSERT INTO example_schema.example_table
(id,
example_column,
rank_asc,
rank_desc)
SELECT
id,
CASE
WHEN col_a IN('a',
'b',
'c') THEN col_a
END AS example_column,
rank_asc,
rank_desc
FROM
another_schema.another_table
test_insert_statement_with_cte_ignored:
pass_str: |
INSERT INTO my_table
WITH my_cte AS (SELECT * FROM t1)
SELECT MAX(field1), field2
FROM t1
test_merge_statements_ignored:
pass_str: |
MERGE INTO t
USING
(
SELECT
DATE_TRUNC('DAY', end_time) AS time_day,
b
FROM u
) AS u ON (a = b)
WHEN MATCHED THEN
UPDATE SET a = b
WHEN NOT MATCHED THEN
INSERT (b) VALUES (c)
test_merge_statement_with_cte_ignored:
pass_str: |
MERGE INTO t
USING
(
WITH my_cte AS (SELECT * FROM t1)
SELECT MAX(field1), field2
FROM t1
) AS u ON (a = b)
WHEN MATCHED THEN
UPDATE SET a = b
WHEN NOT MATCHED THEN
INSERT (b) VALUES (c)
test_create_table_as_select_statements_ignored:
pass_str: |
CREATE TABLE new_table AS (
SELECT
id,
CASE
WHEN col_a IN('a',
'b',
'c') THEN col_a
END AS example_column,
rank_asc,
rank_desc
FROM
another_schema.another_table
)
test_create_table_as_select_with_cte_ignored:
pass_str: |
CREATE TABLE new_table AS (
WITH my_cte AS (SELECT * FROM t1)
SELECT MAX(field1), field2
FROM t1
)
test_fail_fix_explicit_column_references_1:
fail_str: |
SELECT
DATE_TRUNC('DAY', end_time) AS time_day,
b_field
FROM table_name
GROUP BY time_day, b_field
fix_str: |
SELECT
b_field,
DATE_TRUNC('DAY', end_time) AS time_day
FROM table_name
GROUP BY time_day, b_field
test_fail_fix_explicit_column_references_2:
fail_str: |
SELECT
SUM(a_field) OVER (ORDER BY 1) AS a_field_window_sum,
b_field
FROM table_name
GROUP BY a_field_window_sum, b_field
fix_str: |
SELECT
b_field,
SUM(a_field) OVER (ORDER BY 1) AS a_field_window_sum
FROM table_name
GROUP BY a_field_window_sum, b_field
test_fail_no_fix_implicit_column_references:
fail_str: |
SELECT
DATE_TRUNC('DAY', end_time) AS time_day,
b_field
FROM table_name
GROUP BY 1, 2