forked from sqlfluff/sqlfluff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLT01-literals.yml
145 lines (123 loc) · 3.29 KB
/
LT01-literals.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
rule: LT01
test_pass_simple_select:
pass_str: "SELECT 'foo'"
test_pass_expression:
# Test that brackets don't trigger it
pass_str: "SELECT ('foo' || 'bar') as buzz"
test_fail_as:
fail_str: |
SELECT
'foo'AS bar
FROM foo
fix_str: |
SELECT
'foo' AS bar
FROM foo
test_fail_expression:
fail_str: "SELECT ('foo'||'bar') as buzz"
fix_str: "SELECT ('foo' || 'bar') as buzz"
test_pass_comma:
pass_str: |
SELECT
col1,
'string literal' AS new_column_literal,
CASE WHEN col2 IN ('a', 'b') THEN 'Y' ELSE 'N' END AS new_column_case
FROM some_table
WHERE col2 IN ('a', 'b', 'c', 'd');
test_pass_semicolon:
pass_str: |
ALTER SESSION SET TIMEZONE = 'UTC';
configs:
core:
dialect: snowflake
test_pass_bigquery_udf_triple_single_quote:
pass_str: |
CREATE TEMPORARY FUNCTION a()
LANGUAGE js
AS '''
CODE GOES HERE
''';
configs:
core:
dialect: bigquery
test_pass_bigquery_udf_triple_double_quote:
pass_str: |
CREATE TEMPORARY FUNCTION a()
LANGUAGE js
AS """
CODE GOES HERE
""";
configs:
core:
dialect: bigquery
test_pass_ansi_single_quote:
pass_str: "SELECT a + 'b' + 'c' FROM tbl;"
test_fail_ansi_single_quote:
fail_str: "SELECT a +'b'+ 'c' FROM tbl;"
fix_str: "SELECT a + 'b' + 'c' FROM tbl;"
test_pass_tsql_unicode_single_quote:
pass_str: "SELECT a + N'b' + N'c' FROM tbl;"
configs:
core:
dialect: tsql
test_fail_tsql_unicode_single_quote:
fail_str: "SELECT a +N'b'+N'c' FROM tbl;"
fix_str: "SELECT a + N'b' + N'c' FROM tbl;"
configs:
core:
dialect: tsql
test_fail_ansi_unicode_single_quote:
fail_str: "SELECT a + N'b' + N'c' FROM tbl;"
fix_str: "SELECT a + N 'b' + N 'c' FROM tbl;"
configs:
core:
dialect: ansi
test_pass_casting_expression:
pass_str: "SELECT my_date = '2022-01-01'::DATE AS is_current FROM t;"
test_fail_bigquery_casting:
fail_str: "SELECT DATE'2007-01-01';"
fix_str: "SELECT DATE '2007-01-01';"
configs:
core:
dialect: bigquery
test_fail_teradata_casting_type1:
fail_str: "SELECT DATE'2007-01-01' AS the_date;"
fix_str: "SELECT DATE '2007-01-01' AS the_date;"
configs:
core:
dialect: teradata
test_pass_teradata_casting_type2:
fail_str: "SELECT '9999-12-31'(DATE);"
fix_str: "SELECT '9999-12-31' (DATE);"
configs:
core:
dialect: teradata
test_pass_sparksql_ansi_interval_minus:
pass_str: SELECT INTERVAL -'20 15:40:32.99899999' DAY TO SECOND AS col;
configs:
core:
dialect: sparksql
test_pass_sparksql_multi_units_interval_minus:
pass_str: SELECT INTERVAL 2 HOUR -'3' MINUTE AS col;
configs:
core:
dialect: sparksql
test_fail_old_python_test:
fail_str: SELECT a +'b'+'c' FROM tbl;
fix_str: SELECT a + 'b' + 'c' FROM tbl;
violations:
- code: LT01
description: Expected single whitespace between binary operator '+' and quoted literal.
line_no: 1
line_pos: 11
name: layout.spacing
- code: LT01
description: Expected single whitespace between quoted literal and binary operator '+'.
line_no: 1
line_pos: 14
name: layout.spacing
- code: LT01
description: Expected single whitespace between binary operator '+' and quoted literal.
line_no: 1
line_pos: 15
name: layout.spacing