You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
test(analyzer): refactor and move VALUES tests to dedicated file
Reorg VALUES bats tests to its own values.bats from types.bats. Also,
inline the getFieldWithType helper func, improve error messages in
transformValuesNode, and add test cases for case-sensitive quoted column
names and case-differing aggregate columns.
Refs: #1648
run query_server -t -c "SELECT * FROM (VALUES(1, 'a'), (2.5, 'b')) v(num, str);"
69
-
[ "$status"-eq 0 ]
70
-
[[ "$output"=~"1" ]] ||false
71
-
[[ "$output"=~"a" ]] ||false
72
-
[[ "$output"=~"2.5" ]] ||false
73
-
[[ "$output"=~"b" ]] ||false
74
-
}
75
-
76
-
@test 'types: VALUES clause SUM with explicit cast' {
77
-
run query_server -t -c "SELECT SUM(n::numeric) FROM (VALUES(1),(2.01),(3)) v(n);"
78
-
[ "$status"-eq 0 ]
79
-
[[ "$output"=~"6.01" ]] ||false
80
-
}
81
-
82
-
@test 'types: VALUES clause MIN and MAX with mixed types' {
83
-
run query_server -t -c "SELECT MIN(n), MAX(n) FROM (VALUES(1),(2.5),(3),(0.5)) v(n);"
84
-
[ "$status"-eq 0 ]
85
-
[[ "$output"=~"0.5" ]] ||false
86
-
[[ "$output"=~"3" ]] ||false
87
-
}
88
-
89
-
@test 'types: VALUES clause GROUP BY with mixed types' {
90
-
run query_server -t -c "SELECT n, COUNT(*) FROM (VALUES(1),(2.5),(1),(3.5),(2.5)) v(n) GROUP BY n ORDER BY n;"
91
-
[ "$status"-eq 0 ]
92
-
[[ "$output"=~"1" ]] ||false
93
-
[[ "$output"=~"2.5" ]] ||false
94
-
[[ "$output"=~"3.5" ]] ||false
95
-
}
96
-
97
-
@test 'types: VALUES clause SUM GROUP BY with mixed types' {
98
-
run query_server -t -c "SELECT category, SUM(amount) FROM (VALUES('a', 1),('b', 2.5),('a', 3),('b', 4.5)) v(category, amount) GROUP BY category ORDER BY category;"
99
-
[ "$status"-eq 0 ]
100
-
[[ "$output"=~"a" ]] ||false
101
-
[[ "$output"=~"4" ]] ||false
102
-
[[ "$output"=~"b" ]] ||false
103
-
[[ "$output"=~"7.0" ]] ||false
104
-
}
105
-
106
-
@test 'types: VALUES clause DISTINCT with mixed types' {
107
-
run query_server -t -c "SELECT DISTINCT n FROM (VALUES(1),(2.5),(1),(2.5),(3)) v(n) ORDER BY n;"
108
-
[ "$status"-eq 0 ]
109
-
[[ "$output"=~"1" ]] ||false
110
-
[[ "$output"=~"2.5" ]] ||false
111
-
[[ "$output"=~"3" ]] ||false
112
-
}
113
-
114
-
@test 'types: VALUES clause ORDER BY with mixed types' {
115
-
run query_server -t -c "SELECT * FROM (VALUES(3),(1.5),(2),(4.5)) v(n) ORDER BY n;"
116
-
[ "$status"-eq 0 ]
117
-
[[ "$output"=~"1.5" ]] ||false
118
-
[[ "$output"=~"2" ]] ||false
119
-
[[ "$output"=~"3" ]] ||false
120
-
[[ "$output"=~"4.5" ]] ||false
121
-
}
122
-
123
-
@test 'types: VALUES clause ORDER BY DESC with mixed types' {
124
-
run query_server -t -c "SELECT * FROM (VALUES(3),(1.5),(2),(4.5)) v(n) ORDER BY n DESC;"
125
-
[ "$status"-eq 0 ]
126
-
[[ "$output"=~"4.5" ]] ||false
127
-
[[ "$output"=~"3" ]] ||false
128
-
[[ "$output"=~"2" ]] ||false
129
-
[[ "$output"=~"1.5" ]] ||false
130
-
}
131
-
132
-
@test 'types: VALUES clause LIMIT with mixed types' {
133
-
run query_server -t -c "SELECT * FROM (VALUES(1),(2.5),(3),(4.5),(5)) v(n) LIMIT 3;"
134
-
[ "$status"-eq 0 ]
135
-
[[ "$output"=~"1" ]] ||false
136
-
[[ "$output"=~"2.5" ]] ||false
137
-
[[ "$output"=~"3" ]] ||false
138
-
! [[ "$output"=~"4.5" ]] ||false
139
-
! [[ "$output"=~" 5" ]] ||false
140
-
}
141
-
142
-
@test 'types: VALUES clause WHERE filter with mixed types' {
143
-
run query_server -t -c "SELECT * FROM (VALUES(1),(2.5),(3),(4.5),(5)) v(n) WHERE n > 2;"
144
-
[ "$status"-eq 0 ]
145
-
[[ "$output"=~"2.5" ]] ||false
146
-
[[ "$output"=~"3" ]] ||false
147
-
[[ "$output"=~"4.5" ]] ||false
148
-
[[ "$output"=~"5" ]] ||false
149
-
}
150
-
151
-
@test 'types: VALUES clause with NULLs and mixed types' {
152
-
run query_server -t -c "SELECT * FROM (VALUES(1),(NULL),(2.5)) v(n);"
153
-
[ "$status"-eq 0 ]
154
-
[[ "$output"=~"1" ]] ||false
155
-
[[ "$output"=~"2.5" ]] ||false
156
-
}
157
-
158
-
@test 'types: VALUES clause all same type no cast needed' {
159
-
run query_server -t -c "SELECT * FROM (VALUES(1),(2),(3)) v(n);"
160
-
[ "$status"-eq 0 ]
161
-
[[ "$output"=~"1" ]] ||false
162
-
[[ "$output"=~"2" ]] ||false
163
-
[[ "$output"=~"3" ]] ||false
164
-
}
165
-
166
-
@test 'types: VALUES clause all string literals' {
167
-
run query_server -t -c "SELECT * FROM (VALUES('a'),('b'),('c')) v(n);"
0 commit comments