forked from MaterializeInc/materialize
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwhere.slt
138 lines (115 loc) · 2.56 KB
/
where.slt
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
# Copyright 2015 - 2019 The Cockroach Authors. All rights reserved.
# Copyright Materialize, Inc. and contributors. All rights reserved.
#
# Use of this software is governed by the Business Source License
# included in the LICENSE file at the root of this repository.
#
# As of the Change Date specified in that file, in accordance with
# the Business Source License, use of this software will be governed
# by the Apache License, Version 2.0.
#
# This file is derived from the logic test suite in CockroachDB. The
# original file was retrieved on June 10, 2019 from:
#
# https://github.com/cockroachdb/cockroach/blob/d2f7fbf5dd1fc1a099bbad790a2e1f7c60a66cc3/pkg/sql/logictest/testdata/logic_test/where
#
# The original source code is subject to the terms of the Apache
# 2.0 license, a copy of which can be found in the LICENSE file at the
# root of this repository.
mode cockroach
statement ok
CREATE TABLE kv (
k INT PRIMARY KEY,
v INT
)
statement ok
INSERT INTO kv VALUES (1, 2), (3, 4), (5, 6), (7, 8)
statement ok
CREATE TABLE kvString (
k TEXT PRIMARY KEY,
v TEXT
)
statement ok
INSERT INTO kvString VALUES ('like1', 'hell%'), ('like2', 'worl%')
query II rowsort
SELECT * FROM kv WHERE True
----
1 2
3 4
5 6
7 8
query II
SELECT * FROM kv WHERE False
----
query II rowsort
SELECT * FROM kv WHERE k IN (1, 3)
----
1 2
3 4
query II
SELECT * FROM kv WHERE v IN (6)
----
5 6
query II rowsort
SELECT * FROM kv WHERE k IN (SELECT k FROM kv)
----
1 2
3 4
5 6
7 8
query II rowsort
SELECT * FROM kv WHERE (k,v) IN (SELECT * FROM kv)
----
1 2
3 4
5 6
7 8
query error column "nonexistent" does not exist
SELECT * FROM kv WHERE nonexistent = 1
query B
SELECT 'hello' LIKE v FROM kvString WHERE k LIKE 'like%' ORDER BY k
----
true
false
query B
SELECT 'hello' SIMILAR TO v FROM kvString WHERE k SIMILAR TO 'like[1-2]' ORDER BY k
----
true
false
query B
SELECT 'hello' ~ replace(v, '%', '.*') FROM kvString WHERE k ~ 'like[1-2]' ORDER BY k
----
true
false
# Test mixed type tuple comparison.
query II rowsort
SELECT * FROM kv WHERE k IN (1, 5.0, 9)
----
1 2
5 6
# Regression tests for #22670.
statement ok
CREATE TABLE ab (a INT, b INT)
statement ok
INSERT INTO ab VALUES (1, 10), (2, 20), (3, 30), (4, NULL), (NULL, 50), (NULL, NULL)
query II rowsort
SELECT * FROM ab WHERE a IN (1, 3, 4)
----
1 10
3 30
4 NULL
query II rowsort
SELECT * FROM ab WHERE a IN (1, 3, 4, NULL)
----
1 10
3 30
4 NULL
query II rowsort
SELECT * FROM ab WHERE (a, b) IN ((1, 10), (3, 30), (4, 40))
----
1 10
3 30
query II rowsort
SELECT * FROM ab WHERE (a, b) IN ((1, 10), (4, NULL), (NULL, 50))
----
1 10