forked from sqlfluff/sqlfluff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CP05.yml
170 lines (153 loc) · 4.99 KB
/
CP05.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
rule: CP05
test_pass_default_consistent_lower:
# Test that we don't have the "inconsistent" bug
pass_str: |
CREATE TABLE distributors (
did integer,
name varchar(40),
ts time with time zone
);
test_pass_default_consistent_upper:
# Test that we don't have the "inconsistent" bug
pass_str: |
CREATE TABLE distributors (
did INTEGER,
name VARCHAR(40),
ts TIME WITH TIME ZONE
);
test_pass_default_consistent_capitalised:
# Test that we don't have the "inconsistent" bug
pass_str: |
CREATE TABLE distributors (
did Integer,
name Varchar(40),
ts Time With Time Zone
);
test_fail_default_consistent_pascal:
# Attempting Pascal without config defaults to capitalize
fail_str: |
CREATE TABLE distributors (
did Integer,
name VarChar(40),
ts Time With Time Zone
);
fix_str: |
CREATE TABLE distributors (
did Integer,
name Varchar(40),
ts Time With Time Zone
);
test_fail_data_type_inconsistent_capitalisation_1:
# Test that we don't have the "inconsistent" bug
fail_str: CREATE TABLE table1 (account_id BiGinT);
fix_str: CREATE TABLE table1 (account_id BIGINT);
configs:
rules:
capitalisation.types:
extended_capitalisation_policy: upper
test_fail_data_type_inconsistent_capitalisation_2:
fail_str: CREATE TABLE table1 (account_id BiGinT);
fix_str: CREATE TABLE table1 (account_id bigint);
configs:
rules:
capitalisation.types:
extended_capitalisation_policy: lower
test_fail_data_type_inconsistent_capitalisation_3:
fail_str: CREATE TABLE table1 (account_id BiGinT);
fix_str: CREATE TABLE table1 (account_id Bigint);
configs:
rules:
capitalisation.types:
extended_capitalisation_policy: capitalise
test_fail_data_type_capitalisation_policy_lower:
fail_str: CREATE TABLE table1 (account_id BIGINT);
fix_str: CREATE TABLE table1 (account_id bigint);
configs:
rules:
capitalisation.types:
extended_capitalisation_policy: lower
test_fail_data_type_capitalisation_policy_lower_2:
fail_str: CREATE TABLE table1 (account_id BIGINT, column_two varchar(255));
fix_str: CREATE TABLE table1 (account_id bigint, column_two varchar(255));
configs:
rules:
capitalisation.types:
extended_capitalisation_policy: lower
test_fail_data_type_capitalisation_policy_upper:
fail_str: CREATE TABLE table1 (account_id bigint);
fix_str: CREATE TABLE table1 (account_id BIGINT);
configs:
rules:
capitalisation.types:
extended_capitalisation_policy: upper
test_fail_data_type_capitalisation_policy_upper_2:
fail_str: CREATE TABLE table1 (account_id BIGINT, column_two varchar(255));
fix_str: CREATE TABLE table1 (account_id BIGINT, column_two VARCHAR(255));
configs:
rules:
capitalisation.types:
extended_capitalisation_policy: upper
test_fail_data_type_capitalisation_policy_capitalise:
# Test for capitalised casing
fail_str: CREATE TABLE table1 (account_id BIGINT);
fix_str: CREATE TABLE table1 (account_id Bigint);
configs:
rules:
capitalisation.types:
extended_capitalisation_policy: capitalise
test_fail_data_type_capitalisation_policy_keywords_1:
# Test cases where data types are keywords, not data_type_identifiers
# See: https://github.com/sqlfluff/sqlfluff/pull/2121
fail_str: CREATE TABLE table1 (account_id BIGINT, column_two timestamp);
fix_str: CREATE TABLE table1 (account_id BIGINT, column_two TIMESTAMP);
configs:
rules:
capitalisation.types:
extended_capitalisation_policy: upper
test_fail_data_type_capitalisation_policy_keywords_2:
fail_str: CREATE TABLE table1 (account_id BIGINT, column_two timestamp with time zone);
fix_str: CREATE TABLE table1 (account_id BIGINT, column_two TIMESTAMP WITH TIME ZONE);
configs:
rules:
capitalisation.types:
extended_capitalisation_policy: upper
test_pass_sparksql_complex_data_types:
pass_str: |
CREATE TABLE table_identifier(
a STRUCT<b: STRING COMMENT 'struct_comment', c: BOOLEAN> COMMENT 'col_comment',
d MAP<STRING, BOOLEAN> COMMENT 'col_comment',
e ARRAY<STRING> COMMENT 'col_comment'
);
configs:
core:
dialect: sparksql
rules:
capitalisation.types:
extended_capitalisation_policy: upper
test_pass_bigquery_struct_params:
pass_str: |
CREATE TEMPORARY FUNCTION getTableInfo(payload STRING)
RETURNS STRUCT<has_table BOOLEAN, has_th BOOLEAN> LANGUAGE js AS '''
return 1
''';
configs:
core:
dialect: bigquery
rules:
capitalisation.types:
extended_capitalisation_policy: upper
# See https://github.com/sqlfluff/sqlfluff/issues/3277
test_pass_typless_structs_dont_trigger_rule:
pass_str: |
SELECT
STRUCT(
some_field,
some_other_field
) AS col
FROM table
configs:
core:
dialect: bigquery
rules:
capitalisation.types:
extended_capitalisation_policy: upper