-
Notifications
You must be signed in to change notification settings - Fork 3.8k
/
distsql_join
61 lines (44 loc) · 1.81 KB
/
distsql_join
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
# LogicTest: 5node-default-configs
# Test that the distSQL MergeJoiner follows SQL NULL semantics for ON predicate
# equivalence. The use of sorts here force the planning of merge join.
statement ok
CREATE TABLE distsql_mj_test (k INT, v INT)
statement ok
INSERT INTO distsql_mj_test VALUES (0, NULL), (0, 1), (2, 4), (NULL, 4)
# If SQL NULL semantics are not followed, NULL = NULL is truthy. This makes the rows with NULL also appear in the inner join.
query IIII rowsort
SELECT l.k, l.v, r.k, r.v FROM (SELECT * FROM distsql_mj_test ORDER BY k, v) l INNER JOIN (SELECT * FROM distsql_mj_test ORDER BY k, v) r ON l.k = r.k AND l.v = r.v
----
0 1 0 1
2 4 2 4
statement ok
DELETE FROM distsql_mj_test WHERE TRUE;
statement ok
INSERT INTO distsql_mj_test VALUES (0, NULL), (1, NULL), (2, NULL)
# We should not have any results for values with NULLs
query IIII rowsort
SELECT l.k, l.v, r.k, r.v FROM (SELECT * FROM distsql_mj_test ORDER BY k, v) l INNER JOIN (SELECT * FROM distsql_mj_test ORDER BY k, v) r ON l.k = r.k AND l.v = r.v
----
statement ok
DELETE FROM distsql_mj_test WHERE TRUE;
statement ok
INSERT INTO distsql_mj_test VALUES (NULL)
# We shouldn't expect a row of (NULL, NULL), otherwise NULL = NULL was joined.
query II rowsort
SELECT l.k, r.k FROM (SELECT * FROM distsql_mj_test ORDER BY k) l INNER JOIN (SELECT * FROM distsql_mj_test ORDER BY k) r ON l.k = r.k
----
# Regression test for #23001.
statement ok
CREATE TABLE tab0(pk INTEGER PRIMARY KEY, a INTEGER, b INTEGER);
statement ok
INSERT INTO tab0 VALUES(0,1,2);
statement ok
CREATE INDEX on tab0 (a);
query III
SELECT pk, a, b FROM tab0 WHERE a < 10 AND b = 2 ORDER BY a DESC, pk;
----
0 1 2
query T
SELECT feature_name FROM crdb_internal.feature_usage WHERE feature_name='sql.exec.query.is-distributed' AND usage_count > 0
----
sql.exec.query.is-distributed