forked from sqlfluff/sqlfluff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AL03.yml
107 lines (87 loc) · 2.59 KB
/
AL03.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
rule: AL03
test_pass_column_exp_without_alias_1:
pass_str: SELECT *, foo from blah
test_pass_column_exp_without_alias_2:
# AL03 fix with https://github.com/sqlfluff/sqlfluff/issues/449
pass_str: select ps.*, pandgs.blah from ps join pandgs using(moo)
test_pass_column_exp_without_alias_allow_scalar_true:
# Don't expect alias if allow_scalar = True (default)
pass_str: SELECT 1 from blah
test_fail_column_exp_without_alias:
fail_str: SELECT upper(foo), bar from blah
# Casting (via "::TYPE" syntax) has no effect on column output naming
# and AL03 therefore shouldn't be applied
test_pass_column_exp_without_alias_if_only_cast:
pass_str: SELECT foo_col::VARCHAR(28) , bar from blah
test_pass_column_exp_without_alias_if_only_cast_inc_double_cast:
pass_str: SELECT foo_col::INT::VARCHAR , bar from blah
# No catch useless brackets
# output column name is unchanged
test_pass_column_exp_without_alias_if_bracketed:
pass_str: SELECT (foo_col::INT)::VARCHAR , bar from blah
test_fail_column_exp_without_alias_and_cast_fn:
fail_str: SELECT CAST(foo_col AS INT)::VARCHAR , bar from blah
test_fail_column_exp_without_alias_allow_scalar_false:
# Expect alias if allow_scalar = False
fail_str: SELECT 1 from blah
configs:
rules:
allow_scalar: false
test_pass_column_exp_with_alias:
pass_str: SELECT upper(foo) as foo_up, bar from blah
test_pass_function_emits:
# Don't expect alias if allow_scalar = True (default)
pass_str: SELECT json_extract(json_str, '$.AFIELD', '$.BFIELD') emits (cola char(1), colb char(1)) FROM table1
configs:
core:
dialect: exasol
test_fail_cte_no_column_list:
fail_str: |
WITH cte AS (
SELECT
col_a,
min(col_b)
FROM my_table
GROUP BY 1
)
SELECT
a,
b
FROM cte
test_pass_cte_column_list:
pass_str: |
WITH cte(a, b) AS (
SELECT
col_a,
min(col_b)
FROM my_table
GROUP BY 1
)
SELECT
a,
b
FROM cte
test_pass_duckdb_columns_expression:
pass_str: |
SELECT COLUMNS(c -> c LIKE '%num%'), 1 AS x FROM numbers;
configs:
core:
dialect: duckdb
test_pass_duckdb_nested_columns_expression:
pass_str: |
SELECT MIN(COLUMNS(c -> c LIKE '%num%')), 1 AS x FROM numbers;
configs:
core:
dialect: duckdb
test_pass_duckdb_exclude_expression:
pass_str: |
select * exclude (y), 6 as z from tabx;
configs:
core:
dialect: duckdb
test_pass_duckdb_replace_expression:
pass_str: |
select * replace (3 as x), 6 as z from tabx;
configs:
core:
dialect: duckdb