forked from sqlfluff/sqlfluff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LT01-operators.yml
131 lines (107 loc) · 2.79 KB
/
LT01-operators.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: LT01
test_pass_brackets:
# Test that we don't fail * operators in brackets
pass_str: "SELECT COUNT(*) FROM tbl\n\n"
test_pass_expression:
# Github Bug #207
pass_str: |
select
field,
date(field_1) - date(field_2) as diff
from table
test_fail_expression:
# Github Bug #207
fail_str: |
select
field,
date(field_1)-date(field_2) as diff
from table
fix_str: |
select
field,
date(field_1) - date(field_2) as diff
from table
# Check we don't get false alarms with newlines, or sign indicators
# -------------------
test_pass_newline_1:
pass_str: |
SELECT 1
+ 2
test_pass_newline_2:
pass_str: |
SELECT 1
+ 2
test_pass_newline_£:
pass_str: |
SELECT 1
+ 2
test_pass_sign_indicators:
pass_str: SELECT 1, +2, -4
test_pass_tilde:
pass_str: SELECT ~1
# -------------------
fail_simple:
fail_str: "SELECT 1+2"
fix_str: "SELECT 1 + 2"
pass_bigquery_hyphen:
# hyphenated table reference should not fail
pass_str: SELECT col_foo FROM foo-bar.foo.bar
configs:
core:
dialect: bigquery
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
pass_tsql_assignment_operator:
# Test that we fix the outer whitespace but don't add any in between + and =.
fail_str: SET @param1+=1
fix_str: SET @param1 += 1
configs:
core:
dialect: tsql
pass_concat_string:
pass_str: SELECT 'barry' || 'pollard'
test_pass_placeholder_spacing:
# Test for spacing issues around placeholders
# https://github.com/sqlfluff/sqlfluff/issues/4253
pass_str: |
{% set is_dev_environment = true %}
SELECT *
FROM table
WHERE
some_col IS TRUE
{% if is_dev_environment %}
AND created_at >= DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY)
{% else %}
AND created_at >= DATE_SUB(CURRENT_DATE, INTERVAL 30 DAY)
{% endif %}
AND TRUE
;
fail_bigquery_whitespaces_in_function_reference:
fail_str: SELECT dataset . AddFourAndDivide(5, 10)
fix_str: SELECT dataset.AddFourAndDivide(5, 10)
configs:
core:
dialect: bigquery
pass_bigquery_safe_prefix_function:
# SAFE prefix to function calls should not fail
pass_str: SELECT SAFE.STRING(JSON '1')
configs:
core:
dialect: bigquery
fail_bigquery_safe_prefix_function:
# Check that additional whitespaces introduced by
# https://github.com/sqlfluff/sqlfluff/issues/4645
# get fixed.
fail_str: SELECT SAFE . STRING(JSON '1')
fix_str: SELECT SAFE.STRING(JSON '1')
configs:
core:
dialect: bigquery