forked from sqlfluff/sqlfluff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AL02.yml
131 lines (119 loc) · 3.03 KB
/
AL02.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
rule: AL02
issue_561:
# Test for https://github.com/sqlfluff/sqlfluff/issues/561
pass_str: |
select
array_agg(catalog_item_id) within group
(order by product_position asc) over (partition by (event_id, shelf_position))
as shelf_catalog_items
from x
configs:
core:
dialect: snowflake
test_fail_explicit_column_default:
# Test explicit column alias
fail_str: select 1 bar from table1 b
fix_str: select 1 AS bar from table1 b
test_fail_explicit_column_explicit:
# Test explicit column alias
fail_str: select 1 bar from table1 b
fix_str: select 1 AS bar from table1 b
configs:
rules:
aliasing.column:
aliasing: explicit
test_fail_explicit_column_implicit:
# Test explicit column alias
fail_str: select 1 AS bar from table1 b
fix_str: select 1 bar from table1 b
configs:
rules:
aliasing.column:
aliasing: implicit
test_pass_tsql_alternative_alias:
# Test explicit column alias
pass_str: select alias1 = col1
configs:
core:
dialect: tsql
test_fail_alias_ending_equals:
# Test explicit column alias doesn't catch false positives
fail_str: select col1 "example="
fix_str: select col1 AS "example="
test_fail_alias_ending_raw_equals:
# Test explicit column alias doesn't catch false positives
fail_str: select col1 raw_equals
fix_str: select col1 AS raw_equals
test_alias_expression_align_4515_1:
# Test more failing alias expressions
fail_str: |
select
test a
from example_table
fix_str: |
select
test AS a
from example_table
configs:
layout:
type:
alias_expression:
spacing_before: align
align_within: select_clause
align_scope: bracketed
test_alias_expression_align_4515_2:
# Test more failing alias expressions
fail_str: |
select
test a,
test b
from example_table
fix_str: |
select
test AS a,
test AS b
from example_table
configs:
layout:
type:
alias_expression:
spacing_before: align
align_within: select_clause
align_scope: bracketed
test_alias_expression_align_4515_3:
# Test more failing alias expressions
fail_str: |
select
testy_testy_testy a,
test b
from example_table
fix_str: |
select
testy_testy_testy AS a,
test AS b
from example_table
configs:
layout:
type:
alias_expression:
spacing_before: align
align_within: select_clause
align_scope: bracketed
test_fail_alias_expression_oracle_columns:
# Test failing alias expressions
# https://github.com/sqlfluff/sqlfluff/issues/5038
# Skip aliasing with 'AS' for Oracle table expressions
# Still alias the columns with 'AS'
fail_str:
SELECT
base.id id,
base.customer_id cust_id
FROM {{ ref('customers') }} base
fix_str:
SELECT
base.id AS id,
base.customer_id AS cust_id
FROM {{ ref('customers') }} base
configs:
core:
dialect: oracle