More tests for join on key type convert

This commit is contained in:
vdimir 2021-02-19 13:56:08 +03:00
parent 1e37d7c84f
commit ab0719caf0
No known key found for this signature in database
GPG Key ID: F57B3E10A21DBB31
2 changed files with 461 additions and 150 deletions

View File

@ -1,5 +1,5 @@
--- hash ---
- full -
=== hash ===
= full =
-4 0 196
-3 0 197
-2 0 198
@ -15,7 +15,7 @@
8 108 \N
9 109 \N
10 110 \N
- left -
= left =
1 101 201
2 102 202
3 103 203
@ -26,7 +26,7 @@
8 108 \N
9 109 \N
10 110 \N
- right -
= right =
-4 0 196
-3 0 197
-2 0 198
@ -37,13 +37,13 @@
3 103 203
4 104 204
5 105 205
- inner -
= inner =
1 101 201
2 102 202
3 103 203
4 104 204
5 105 205
- full -
= full =
0 0 -4
0 0 -3
0 0 -2
@ -59,7 +59,7 @@
8 8 0
9 9 0
10 10 0
- left -
= left =
1 1 1
2 2 2
3 3 3
@ -70,7 +70,7 @@
8 8 0
9 9 0
10 10 0
- right -
= right =
0 0 -4
0 0 -3
0 0 -2
@ -81,14 +81,14 @@
3 3 3
4 4 4
5 5 5
- inner -
= inner =
1 1 1
2 2 2
3 3 3
4 4 4
5 5 5
- join on -
- full -
= join on =
= full =
0 0 -4 196
0 0 -3 197
0 0 -2 198
@ -104,7 +104,7 @@
8 108 0 \N
9 109 0 \N
10 110 0 \N
- left -
= left =
1 101 1 201
2 102 2 202
3 103 3 203
@ -115,7 +115,7 @@
8 108 0 \N
9 109 0 \N
10 110 0 \N
- right -
= right =
0 0 -4 196
0 0 -3 197
0 0 -2 198
@ -126,26 +126,80 @@
3 103 3 203
4 104 4 204
5 105 5 205
- inner -
= inner =
1 101 1 201
2 102 2 202
3 103 3 203
4 104 4 204
5 105 5 205
- agg -
= full =
0 0 -4 196
0 0 -3 197
0 0 -2 198
0 0 -1 199
0 0 0 200
1 101 1 201
2 102 2 202
3 103 3 203
4 104 4 204
5 105 5 205
6 106 0 \N
7 107 0 \N
8 108 0 \N
9 109 0 \N
10 110 0 \N
= left =
1 101 1 201
2 102 2 202
3 103 3 203
4 104 4 204
5 105 5 205
6 106 0 \N
7 107 0 \N
8 108 0 \N
9 109 0 \N
10 110 0 \N
= right =
0 0 -4 196
0 0 -3 197
0 0 -2 198
0 0 -1 199
0 0 0 200
1 101 1 201
2 102 2 202
3 103 3 203
4 104 4 204
5 105 5 205
= inner =
1 101 1 201
2 102 2 202
3 103 3 203
4 104 4 204
5 105 5 205
= agg =
1
1
1
1
- types -
1
0 -10 0
1 55 1055
0 0 -10 0 990
1 55 15 1055 1015
= types =
1
1
1
1
1
1
--- partial_merge ---
- full -
1
1
1
1
1
=== partial_merge ===
= full =
-4 0 196
-3 0 197
-2 0 198
@ -161,7 +215,7 @@
8 108 \N
9 109 \N
10 110 \N
- left -
= left =
1 101 201
2 102 202
3 103 203
@ -172,7 +226,7 @@
8 108 \N
9 109 \N
10 110 \N
- right -
= right =
-4 0 196
-3 0 197
-2 0 198
@ -183,13 +237,13 @@
3 103 203
4 104 204
5 105 205
- inner -
= inner =
1 101 201
2 102 202
3 103 203
4 104 204
5 105 205
- full -
= full =
0 0 -4
0 0 -3
0 0 -2
@ -205,7 +259,7 @@
8 8 0
9 9 0
10 10 0
- left -
= left =
1 1 1
2 2 2
3 3 3
@ -216,7 +270,7 @@
8 8 0
9 9 0
10 10 0
- right -
= right =
0 0 -4
0 0 -3
0 0 -2
@ -227,14 +281,14 @@
3 3 3
4 4 4
5 5 5
- inner -
= inner =
1 1 1
2 2 2
3 3 3
4 4 4
5 5 5
- join on -
- full -
= join on =
= full =
0 0 -4 196
0 0 -3 197
0 0 -2 198
@ -250,7 +304,7 @@
8 108 0 \N
9 109 0 \N
10 110 0 \N
- left -
= left =
1 101 1 201
2 102 2 202
3 103 3 203
@ -261,7 +315,7 @@
8 108 0 \N
9 109 0 \N
10 110 0 \N
- right -
= right =
0 0 -4 196
0 0 -3 197
0 0 -2 198
@ -272,26 +326,80 @@
3 103 3 203
4 104 4 204
5 105 5 205
- inner -
= inner =
1 101 1 201
2 102 2 202
3 103 3 203
4 104 4 204
5 105 5 205
- agg -
= full =
0 0 -4 196
0 0 -3 197
0 0 -2 198
0 0 -1 199
0 0 0 200
1 101 1 201
2 102 2 202
3 103 3 203
4 104 4 204
5 105 5 205
6 106 0 \N
7 107 0 \N
8 108 0 \N
9 109 0 \N
10 110 0 \N
= left =
1 101 1 201
2 102 2 202
3 103 3 203
4 104 4 204
5 105 5 205
6 106 0 \N
7 107 0 \N
8 108 0 \N
9 109 0 \N
10 110 0 \N
= right =
0 0 -4 196
0 0 -3 197
0 0 -2 198
0 0 -1 199
0 0 0 200
1 101 1 201
2 102 2 202
3 103 3 203
4 104 4 204
5 105 5 205
= inner =
1 101 1 201
2 102 2 202
3 103 3 203
4 104 4 204
5 105 5 205
= agg =
1
1
1
1
- types -
1
0 -10 0
1 55 1055
0 0 -10 0 990
1 55 15 1055 1015
= types =
1
1
1
1
1
1
--- switch ---
- full -
1
1
1
1
1
=== switch ===
= full =
-4 0 196
-3 0 197
-2 0 198
@ -307,7 +415,7 @@
8 108 \N
9 109 \N
10 110 \N
- left -
= left =
1 101 201
2 102 202
3 103 203
@ -318,7 +426,7 @@
8 108 \N
9 109 \N
10 110 \N
- right -
= right =
-4 0 196
-3 0 197
-2 0 198
@ -329,13 +437,13 @@
3 103 203
4 104 204
5 105 205
- inner -
= inner =
1 101 201
2 102 202
3 103 203
4 104 204
5 105 205
- full -
= full =
0 0 -4
0 0 -3
0 0 -2
@ -351,7 +459,7 @@
8 8 0
9 9 0
10 10 0
- left -
= left =
1 1 1
2 2 2
3 3 3
@ -362,7 +470,7 @@
8 8 0
9 9 0
10 10 0
- right -
= right =
0 0 -4
0 0 -3
0 0 -2
@ -373,14 +481,14 @@
3 3 3
4 4 4
5 5 5
- inner -
= inner =
1 1 1
2 2 2
3 3 3
4 4 4
5 5 5
- join on -
- full -
= join on =
= full =
0 0 -4 196
0 0 -3 197
0 0 -2 198
@ -396,7 +504,7 @@
8 108 0 \N
9 109 0 \N
10 110 0 \N
- left -
= left =
1 101 1 201
2 102 2 202
3 103 3 203
@ -407,7 +515,7 @@
8 108 0 \N
9 109 0 \N
10 110 0 \N
- right -
= right =
0 0 -4 196
0 0 -3 197
0 0 -2 198
@ -418,26 +526,80 @@
3 103 3 203
4 104 4 204
5 105 5 205
- inner -
= inner =
1 101 1 201
2 102 2 202
3 103 3 203
4 104 4 204
5 105 5 205
- agg -
= full =
0 0 -4 196
0 0 -3 197
0 0 -2 198
0 0 -1 199
0 0 0 200
1 101 1 201
2 102 2 202
3 103 3 203
4 104 4 204
5 105 5 205
6 106 0 \N
7 107 0 \N
8 108 0 \N
9 109 0 \N
10 110 0 \N
= left =
1 101 1 201
2 102 2 202
3 103 3 203
4 104 4 204
5 105 5 205
6 106 0 \N
7 107 0 \N
8 108 0 \N
9 109 0 \N
10 110 0 \N
= right =
0 0 -4 196
0 0 -3 197
0 0 -2 198
0 0 -1 199
0 0 0 200
1 101 1 201
2 102 2 202
3 103 3 203
4 104 4 204
5 105 5 205
= inner =
1 101 1 201
2 102 2 202
3 103 3 203
4 104 4 204
5 105 5 205
= agg =
1
1
1
1
- types -
1
0 -10 0
1 55 1055
0 0 -10 0 990
1 55 15 1055 1015
= types =
1
1
1
1
1
1
--- join use nulls ---
- full -
1
1
1
1
1
=== join use nulls ===
= full =
-4 \N 196
-3 \N 197
-2 \N 198
@ -453,7 +615,7 @@
8 108 \N
9 109 \N
10 110 \N
- right -
= right =
-4 \N 196
-3 \N 197
-2 \N 198
@ -464,61 +626,105 @@
3 103 203
4 104 204
5 105 205
---
--- hash ---
- full -
==========
=== hash ===
= full =
1 1
2 2
-1 1
1 \N
1 257
1 -1
- left -
= left =
1 1
2 2
- right -
= right =
1 1
-1 1
1 \N
1 257
1 -1
- inner -
= inner =
1 1
- agg -
= full =
1 1 1 1
2 2 0 \N
0 0 -1 1
0 0 1 \N
0 0 1 257
0 0 1 -1
= left =
1 1 1 1
2 2 0 \N
= right =
1 1 1 1
0 0 -1 1
0 0 1 \N
0 0 1 257
0 0 1 -1
= inner =
1 1 1 1
= agg =
5 260
3 3
3 258
1 1
- types -
1
1
1
1
--- partial_merge ---
- full -
1 1
2 2
-1 1
1 \N
1 257
1 -1
- left -
1 1
2 2
- right -
1 1
-1 1
1 \N
1 257
1 -1
- inner -
1 1
- agg -
5 260
3 3
3 258
1 1
- types -
= types =
1
1
1
1
=== partial_merge ===
= full =
1 1
2 2
-1 1
1 \N
1 257
1 -1
= left =
1 1
2 2
= right =
1 1
-1 1
1 \N
1 257
1 -1
= inner =
1 1
= full =
1 1 1 1
2 2 0 \N
0 0 -1 1
0 0 1 \N
0 0 1 257
0 0 1 -1
= left =
1 1 1 1
2 2 0 \N
= right =
1 1 1 1
0 0 -1 1
0 0 1 \N
0 0 1 257
0 0 1 -1
= inner =
1 1 1 1
= agg =
5 260
3 3
3 258
1 1
5 260
3 3
3 258
1 1
= types =
1
1
1

View File

@ -7,46 +7,65 @@ CREATE TABLE t2 (a Int16, b Nullable(Int64)) ENGINE = TinyLog;
INSERT INTO t1 SELECT number as a, 100 + number as b FROM system.numbers LIMIT 1, 10;
INSERT INTO t2 SELECT number - 5 as a, 200 + number - 5 as b FROM system.numbers LIMIT 1, 10;
SELECT '--- hash ---';
SELECT '=== hash ===';
SET join_algorithm = 'hash';
SELECT '- full -';
SELECT '= full =';
SELECT a, b, t2.b FROM t1 FULL JOIN t2 USING (a) ORDER BY (a);
SELECT '- left -';
SELECT '= left =';
SELECT a, b, t2.b FROM t1 LEFT JOIN t2 USING (a) ORDER BY (a);
SELECT '- right -';
SELECT '= right =';
SELECT a, b, t2.b FROM t1 RIGHT JOIN t2 USING (a) ORDER BY (a);
SELECT '- inner -';
SELECT '= inner =';
SELECT a, b, t2.b FROM t1 INNER JOIN t2 USING (a) ORDER BY (a);
SELECT '- full -';
SELECT '= full =';
SELECT a, t1.a, t2.a FROM t1 FULL JOIN t2 USING (a) ORDER BY (t1.a, t2.a);
SELECT '- left -';
SELECT '= left =';
SELECT a, t1.a, t2.a FROM t1 LEFT JOIN t2 USING (a) ORDER BY (t1.a, t2.a);
SELECT '- right -';
SELECT '= right =';
SELECT a, t1.a, t2.a FROM t1 RIGHT JOIN t2 USING (a) ORDER BY (t1.a, t2.a);
SELECT '- inner -';
SELECT '= inner =';
SELECT a, t1.a, t2.a FROM t1 INNER JOIN t2 USING (a) ORDER BY (t1.a, t2.a);
SELECT '- join on -';
SELECT '- full -';
SELECT '= join on =';
SELECT '= full =';
SELECT a, b, t2.a, t2.b FROM t1 FULL JOIN t2 ON (t1.a == t2.a) ORDER BY (t1.a, t2.a);
SELECT '- left -';
SELECT '= left =';
SELECT a, b, t2.a, t2.b FROM t1 LEFT JOIN t2 ON (t1.a == t2.a) ORDER BY (t1.a, t2.a);
SELECT '- right -';
SELECT '= right =';
SELECT a, b, t2.a, t2.b FROM t1 RIGHT JOIN t2 ON (t1.a == t2.a) ORDER BY (t1.a, t2.a);
SELECT '- inner -';
SELECT '= inner =';
SELECT a, b, t2.a, t2.b FROM t1 INNER JOIN t2 ON (t1.a == t2.a) ORDER BY (t1.a, t2.a);
SELECT '- agg -';
SELECT '= full =';
SELECT * FROM t1 FULL JOIN t2 ON (t1.a + t1.b = t2.a + t2.b - 100) ORDER BY (t1.a, t2.a);
SELECT '= left =';
SELECT * FROM t1 LEFT JOIN t2 ON (t1.a + t1.b = t2.a + t2.b - 100) ORDER BY (t1.a, t2.a);
SELECT '= right =';
SELECT * FROM t1 RIGHT JOIN t2 ON (t1.a + t1.b = t2.a + t2.b - 100) ORDER BY (t1.a, t2.a);
SELECT '= inner =';
SELECT * FROM t1 INNER JOIN t2 ON (t1.a + t1.b = t2.a + t2.b - 100) ORDER BY (t1.a, t2.a);
-- Int64 and UInt64 has no supertype
SELECT * FROM t1 FULL JOIN t2 ON (t1.a + t1.b + 100 = t2.a + t2.b) ORDER BY (t1.a, t2.a); -- { serverError 53 }
SELECT * FROM t1 LEFT JOIN t2 ON (t1.a + t1.b + 100 = t2.a + t2.b) ORDER BY (t1.a, t2.a); -- { serverError 53 }
SELECT * FROM t1 RIGHT JOIN t2 ON (t1.a + t1.b + 100 = t2.a + t2.b) ORDER BY (t1.a, t2.a); -- { serverError 53 }
SELECT * FROM t1 INNER JOIN t2 ON (t1.a + t1.b + 100 = t2.a + t2.b) ORDER BY (t1.a, t2.a); -- { serverError 53 }
SELECT '= agg =';
SELECT sum(a) == 7 FROM t1 FULL JOIN t2 USING (a) WHERE b > 102 AND t2.b <= 204;
SELECT sum(a) == 7 FROM t1 INNER JOIN t2 USING (a) WHERE b > 102 AND t2.b <= 204;
SELECT sum(b) = 103 FROM t1 LEFT JOIN t2 USING (a) WHERE b > 102 AND t2.b < 204;
SELECT sum(t2.b) = 203 FROM t1 RIGHT JOIN t2 USING (a) WHERE b > 102 AND t2.b < 204;
SELECT '- types -';
SELECT sum(a) == 2 + 3 + 4 FROM t1 FULL JOIN t2 ON (t1.a + t1.b = t2.a + t2.b - 100) WHERE t1.b < 105 AND t2.b > 201;
SELECT a > 0, sum(a), sum(b) FROM t1 FULL JOIN t2 USING (a) GROUP BY (a > 0) ORDER BY a > 0;
SELECT a > 0, sum(a), sum(t2.a), sum(b), sum(t2.b) FROM t1 FULL JOIN t2 ON (t1.a == t2.a) GROUP BY (a > 0) ORDER BY a > 0;
SELECT '= types =';
SELECT any(toTypeName(a)) == 'Int32' AND any(toTypeName(t2.a)) == 'Int32' FROM t1 FULL JOIN t2 USING (a);
SELECT any(toTypeName(a)) == 'Int32' AND any(toTypeName(t2.a)) == 'Int32' FROM t1 LEFT JOIN t2 USING (a);
SELECT any(toTypeName(a)) == 'Int32' AND any(toTypeName(t2.a)) == 'Int32' FROM t1 RIGHT JOIN t2 USING (a);
@ -55,46 +74,72 @@ SELECT any(toTypeName(a)) == 'Int32' AND any(toTypeName(t2.a)) == 'Int32' FROM t
SELECT toTypeName(any(a)) == 'Int32' AND toTypeName(any(t2.a)) == 'Int32' FROM t1 FULL JOIN t2 USING (a);
SELECT min(toTypeName(a) == 'Int32' AND toTypeName(t2.a) == 'Int32') FROM t1 FULL JOIN t2 USING (a);
SELECT '--- partial_merge ---';
SELECT any(toTypeName(a)) == 'UInt16' AND any(toTypeName(t2.a)) == 'Int16' FROM t1 FULL JOIN t2 ON (t1.a == t2.a);
SELECT any(toTypeName(a)) == 'UInt16' AND any(toTypeName(t2.a)) == 'Int16' FROM t1 LEFT JOIN t2 ON (t1.a == t2.a);
SELECT any(toTypeName(a)) == 'UInt16' AND any(toTypeName(t2.a)) == 'Int16' FROM t1 RIGHT JOIN t2 ON (t1.a == t2.a);
SELECT any(toTypeName(a)) == 'UInt16' AND any(toTypeName(t2.a)) == 'Int16' FROM t1 INNER JOIN t2 ON (t1.a == t2.a);
SELECT toTypeName(any(a)) == 'UInt16' AND toTypeName(any(t2.a)) == 'Int16' FROM t1 FULL JOIN t2 ON (t1.a == t2.a);
SELECT '=== partial_merge ===';
SET join_algorithm = 'partial_merge';
SELECT '- full -';
SELECT '= full =';
SELECT a, b, t2.b FROM t1 FULL JOIN t2 USING (a) ORDER BY (a);
SELECT '- left -';
SELECT '= left =';
SELECT a, b, t2.b FROM t1 LEFT JOIN t2 USING (a) ORDER BY (a);
SELECT '- right -';
SELECT '= right =';
SELECT a, b, t2.b FROM t1 RIGHT JOIN t2 USING (a) ORDER BY (a);
SELECT '- inner -';
SELECT '= inner =';
SELECT a, b, t2.b FROM t1 INNER JOIN t2 USING (a) ORDER BY (a);
SELECT '- full -';
SELECT '= full =';
SELECT a, t1.a, t2.a FROM t1 FULL JOIN t2 USING (a) ORDER BY (t1.a, t2.a);
SELECT '- left -';
SELECT '= left =';
SELECT a, t1.a, t2.a FROM t1 LEFT JOIN t2 USING (a) ORDER BY (t1.a, t2.a);
SELECT '- right -';
SELECT '= right =';
SELECT a, t1.a, t2.a FROM t1 RIGHT JOIN t2 USING (a) ORDER BY (t1.a, t2.a);
SELECT '- inner -';
SELECT '= inner =';
SELECT a, t1.a, t2.a FROM t1 INNER JOIN t2 USING (a) ORDER BY (t1.a, t2.a);
SELECT '- join on -';
SELECT '- full -';
SELECT '= join on =';
SELECT '= full =';
SELECT a, b, t2.a, t2.b FROM t1 FULL JOIN t2 ON (t1.a == t2.a) ORDER BY (t1.a, t2.a);
SELECT '- left -';
SELECT '= left =';
SELECT a, b, t2.a, t2.b FROM t1 LEFT JOIN t2 ON (t1.a == t2.a) ORDER BY (t1.a, t2.a);
SELECT '- right -';
SELECT '= right =';
SELECT a, b, t2.a, t2.b FROM t1 RIGHT JOIN t2 ON (t1.a == t2.a) ORDER BY (t1.a, t2.a);
SELECT '- inner -';
SELECT '= inner =';
SELECT a, b, t2.a, t2.b FROM t1 INNER JOIN t2 ON (t1.a == t2.a) ORDER BY (t1.a, t2.a);
SELECT '- agg -';
SELECT '= full =';
SELECT * FROM t1 FULL JOIN t2 ON (t1.a + t1.b = t2.a + t2.b - 100) ORDER BY (t1.a, t2.a);
SELECT '= left =';
SELECT * FROM t1 LEFT JOIN t2 ON (t1.a + t1.b = t2.a + t2.b - 100) ORDER BY (t1.a, t2.a);
SELECT '= right =';
SELECT * FROM t1 RIGHT JOIN t2 ON (t1.a + t1.b = t2.a + t2.b - 100) ORDER BY (t1.a, t2.a);
SELECT '= inner =';
SELECT * FROM t1 INNER JOIN t2 ON (t1.a + t1.b = t2.a + t2.b - 100) ORDER BY (t1.a, t2.a);
-- Int64 and UInt64 has no supertype
SELECT * FROM t1 FULL JOIN t2 ON (t1.a + t1.b + 100 = t2.a + t2.b) ORDER BY (t1.a, t2.a); -- { serverError 53 }
SELECT * FROM t1 LEFT JOIN t2 ON (t1.a + t1.b + 100 = t2.a + t2.b) ORDER BY (t1.a, t2.a); -- { serverError 53 }
SELECT * FROM t1 RIGHT JOIN t2 ON (t1.a + t1.b + 100 = t2.a + t2.b) ORDER BY (t1.a, t2.a); -- { serverError 53 }
SELECT * FROM t1 INNER JOIN t2 ON (t1.a + t1.b + 100 = t2.a + t2.b) ORDER BY (t1.a, t2.a); -- { serverError 53 }
SELECT '= agg =';
SELECT sum(a) == 7 FROM t1 FULL JOIN t2 USING (a) WHERE b > 102 AND t2.b <= 204;
SELECT sum(a) == 7 FROM t1 INNER JOIN t2 USING (a) WHERE b > 102 AND t2.b <= 204;
SELECT sum(b) = 103 FROM t1 LEFT JOIN t2 USING (a) WHERE b > 102 AND t2.b < 204;
SELECT sum(t2.b) = 203 FROM t1 RIGHT JOIN t2 USING (a) WHERE b > 102 AND t2.b < 204;
SELECT '- types -';
SELECT sum(a) == 2 + 3 + 4 FROM t1 FULL JOIN t2 ON (t1.a + t1.b = t2.a + t2.b - 100) WHERE t1.b < 105 AND t2.b > 201;
SELECT a > 0, sum(a), sum(b) FROM t1 FULL JOIN t2 USING (a) GROUP BY (a > 0) ORDER BY a > 0;
SELECT a > 0, sum(a), sum(t2.a), sum(b), sum(t2.b) FROM t1 FULL JOIN t2 ON (t1.a == t2.a) GROUP BY (a > 0) ORDER BY a > 0;
SELECT '= types =';
SELECT any(toTypeName(a)) == 'Int32' AND any(toTypeName(t2.a)) == 'Int32' FROM t1 FULL JOIN t2 USING (a);
SELECT any(toTypeName(a)) == 'Int32' AND any(toTypeName(t2.a)) == 'Int32' FROM t1 LEFT JOIN t2 USING (a);
SELECT any(toTypeName(a)) == 'Int32' AND any(toTypeName(t2.a)) == 'Int32' FROM t1 RIGHT JOIN t2 USING (a);
@ -103,47 +148,73 @@ SELECT any(toTypeName(a)) == 'Int32' AND any(toTypeName(t2.a)) == 'Int32' FROM t
SELECT toTypeName(any(a)) == 'Int32' AND toTypeName(any(t2.a)) == 'Int32' FROM t1 FULL JOIN t2 USING (a);
SELECT min(toTypeName(a) == 'Int32' AND toTypeName(t2.a) == 'Int32') FROM t1 FULL JOIN t2 USING (a);
SELECT '--- switch ---';
SELECT any(toTypeName(a)) == 'UInt16' AND any(toTypeName(t2.a)) == 'Int16' FROM t1 FULL JOIN t2 ON (t1.a == t2.a);
SELECT any(toTypeName(a)) == 'UInt16' AND any(toTypeName(t2.a)) == 'Int16' FROM t1 LEFT JOIN t2 ON (t1.a == t2.a);
SELECT any(toTypeName(a)) == 'UInt16' AND any(toTypeName(t2.a)) == 'Int16' FROM t1 RIGHT JOIN t2 ON (t1.a == t2.a);
SELECT any(toTypeName(a)) == 'UInt16' AND any(toTypeName(t2.a)) == 'Int16' FROM t1 INNER JOIN t2 ON (t1.a == t2.a);
SELECT toTypeName(any(a)) == 'UInt16' AND toTypeName(any(t2.a)) == 'Int16' FROM t1 FULL JOIN t2 ON (t1.a == t2.a);
SELECT '=== switch ===';
SET join_algorithm = 'auto';
SET max_bytes_in_join = 100;
SELECT '- full -';
SELECT '= full =';
SELECT a, b, t2.b FROM t1 FULL JOIN t2 USING (a) ORDER BY (a);
SELECT '- left -';
SELECT '= left =';
SELECT a, b, t2.b FROM t1 LEFT JOIN t2 USING (a) ORDER BY (a);
SELECT '- right -';
SELECT '= right =';
SELECT a, b, t2.b FROM t1 RIGHT JOIN t2 USING (a) ORDER BY (a);
SELECT '- inner -';
SELECT '= inner =';
SELECT a, b, t2.b FROM t1 INNER JOIN t2 USING (a) ORDER BY (a);
SELECT '- full -';
SELECT '= full =';
SELECT a, t1.a, t2.a FROM t1 FULL JOIN t2 USING (a) ORDER BY (t1.a, t2.a);
SELECT '- left -';
SELECT '= left =';
SELECT a, t1.a, t2.a FROM t1 LEFT JOIN t2 USING (a) ORDER BY (t1.a, t2.a);
SELECT '- right -';
SELECT '= right =';
SELECT a, t1.a, t2.a FROM t1 RIGHT JOIN t2 USING (a) ORDER BY (t1.a, t2.a);
SELECT '- inner -';
SELECT '= inner =';
SELECT a, t1.a, t2.a FROM t1 INNER JOIN t2 USING (a) ORDER BY (t1.a, t2.a);
SELECT '- join on -';
SELECT '- full -';
SELECT '= join on =';
SELECT '= full =';
SELECT a, b, t2.a, t2.b FROM t1 FULL JOIN t2 ON (t1.a == t2.a) ORDER BY (t1.a, t2.a);
SELECT '- left -';
SELECT '= left =';
SELECT a, b, t2.a, t2.b FROM t1 LEFT JOIN t2 ON (t1.a == t2.a) ORDER BY (t1.a, t2.a);
SELECT '- right -';
SELECT '= right =';
SELECT a, b, t2.a, t2.b FROM t1 RIGHT JOIN t2 ON (t1.a == t2.a) ORDER BY (t1.a, t2.a);
SELECT '- inner -';
SELECT '= inner =';
SELECT a, b, t2.a, t2.b FROM t1 INNER JOIN t2 ON (t1.a == t2.a) ORDER BY (t1.a, t2.a);
SELECT '- agg -';
SELECT '= full =';
SELECT * FROM t1 FULL JOIN t2 ON (t1.a + t1.b = t2.a + t2.b - 100) ORDER BY (t1.a, t2.a);
SELECT '= left =';
SELECT * FROM t1 LEFT JOIN t2 ON (t1.a + t1.b = t2.a + t2.b - 100) ORDER BY (t1.a, t2.a);
SELECT '= right =';
SELECT * FROM t1 RIGHT JOIN t2 ON (t1.a + t1.b = t2.a + t2.b - 100) ORDER BY (t1.a, t2.a);
SELECT '= inner =';
SELECT * FROM t1 INNER JOIN t2 ON (t1.a + t1.b = t2.a + t2.b - 100) ORDER BY (t1.a, t2.a);
-- Int64 and UInt64 has no supertype
SELECT * FROM t1 FULL JOIN t2 ON (t1.a + t1.b + 100 = t2.a + t2.b) ORDER BY (t1.a, t2.a); -- { serverError 53 }
SELECT * FROM t1 LEFT JOIN t2 ON (t1.a + t1.b + 100 = t2.a + t2.b) ORDER BY (t1.a, t2.a); -- { serverError 53 }
SELECT * FROM t1 RIGHT JOIN t2 ON (t1.a + t1.b + 100 = t2.a + t2.b) ORDER BY (t1.a, t2.a); -- { serverError 53 }
SELECT * FROM t1 INNER JOIN t2 ON (t1.a + t1.b + 100 = t2.a + t2.b) ORDER BY (t1.a, t2.a); -- { serverError 53 }
SELECT '= agg =';
SELECT sum(a) == 7 FROM t1 FULL JOIN t2 USING (a) WHERE b > 102 AND t2.b <= 204;
SELECT sum(a) == 7 FROM t1 INNER JOIN t2 USING (a) WHERE b > 102 AND t2.b <= 204;
SELECT sum(b) = 103 FROM t1 LEFT JOIN t2 USING (a) WHERE b > 102 AND t2.b < 204;
SELECT sum(t2.b) = 203 FROM t1 RIGHT JOIN t2 USING (a) WHERE b > 102 AND t2.b < 204;
SELECT '- types -';
SELECT sum(a) == 2 + 3 + 4 FROM t1 FULL JOIN t2 ON (t1.a + t1.b = t2.a + t2.b - 100) WHERE t1.b < 105 AND t2.b > 201;
SELECT a > 0, sum(a), sum(b) FROM t1 FULL JOIN t2 USING (a) GROUP BY (a > 0) ORDER BY a > 0;
SELECT a > 0, sum(a), sum(t2.a), sum(b), sum(t2.b) FROM t1 FULL JOIN t2 ON (t1.a == t2.a) GROUP BY (a > 0) ORDER BY a > 0;
SELECT '= types =';
SELECT any(toTypeName(a)) == 'Int32' AND any(toTypeName(t2.a)) == 'Int32' FROM t1 FULL JOIN t2 USING (a);
SELECT any(toTypeName(a)) == 'Int32' AND any(toTypeName(t2.a)) == 'Int32' FROM t1 LEFT JOIN t2 USING (a);
SELECT any(toTypeName(a)) == 'Int32' AND any(toTypeName(t2.a)) == 'Int32' FROM t1 RIGHT JOIN t2 USING (a);
@ -152,15 +223,21 @@ SELECT any(toTypeName(a)) == 'Int32' AND any(toTypeName(t2.a)) == 'Int32' FROM t
SELECT toTypeName(any(a)) == 'Int32' AND toTypeName(any(t2.a)) == 'Int32' FROM t1 FULL JOIN t2 USING (a);
SELECT min(toTypeName(a) == 'Int32' AND toTypeName(t2.a) == 'Int32') FROM t1 FULL JOIN t2 USING (a);
SELECT any(toTypeName(a)) == 'UInt16' AND any(toTypeName(t2.a)) == 'Int16' FROM t1 FULL JOIN t2 ON (t1.a == t2.a);
SELECT any(toTypeName(a)) == 'UInt16' AND any(toTypeName(t2.a)) == 'Int16' FROM t1 LEFT JOIN t2 ON (t1.a == t2.a);
SELECT any(toTypeName(a)) == 'UInt16' AND any(toTypeName(t2.a)) == 'Int16' FROM t1 RIGHT JOIN t2 ON (t1.a == t2.a);
SELECT any(toTypeName(a)) == 'UInt16' AND any(toTypeName(t2.a)) == 'Int16' FROM t1 INNER JOIN t2 ON (t1.a == t2.a);
SELECT toTypeName(any(a)) == 'UInt16' AND toTypeName(any(t2.a)) == 'Int16' FROM t1 FULL JOIN t2 ON (t1.a == t2.a);
SET max_bytes_in_join = 0;
SELECT '--- join use nulls ---';
SELECT '=== join use nulls ===';
SET join_use_nulls = 1;
SELECT '- full -';
SELECT '= full =';
SELECT a, b, t2.b FROM t1 FULL JOIN t2 USING (a) ORDER BY (a);
SELECT '- right -';
SELECT '= right =';
SELECT a, b, t2.b FROM t1 RIGHT JOIN t2 USING (a) ORDER BY (a);
SET join_use_nulls = 0;
@ -168,7 +245,7 @@ SET join_use_nulls = 0;
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
SELECT '---';
SELECT '==========';
DROP TABLE IF EXISTS t_ab1;
DROP TABLE IF EXISTS t_ab2;
@ -178,52 +255,80 @@ CREATE TABLE t_ab2 (id Nullable(Int32), a Int16, b Nullable(Int64)) ENGINE = Tin
INSERT INTO t_ab1 VALUES (0, 1, 1), (1, 2, 2);
INSERT INTO t_ab2 VALUES (2, -1, 1), (3, 1, NULL), (4, 1, 257), (5, 1, -1), (6, 1, 1);
SELECT '--- hash ---';
SELECT '=== hash ===';
SET join_algorithm = 'hash';
SELECT '- full -';
SELECT '= full =';
SELECT a, b FROM t_ab1 FULL JOIN t_ab2 USING (a, b) ORDER BY ifNull(t_ab1.id, t_ab2.id);
SELECT '- left -';
SELECT '= left =';
SELECT a, b FROM t_ab1 LEFT JOIN t_ab2 USING (a, b) ORDER BY ifNull(t_ab1.id, t_ab2.id);
SELECT '- right -';
SELECT '= right =';
SELECT a, b FROM t_ab1 RIGHT JOIN t_ab2 USING (a, b) ORDER BY ifNull(t_ab1.id, t_ab2.id);
SELECT '- inner -';
SELECT '= inner =';
SELECT a, b FROM t_ab1 INNER JOIN t_ab2 USING (a, b) ORDER BY ifNull(t_ab1.id, t_ab2.id);
SELECT '- agg -';
SELECT '= full =';
SELECT a, b, t_ab2.a, t_ab2.b FROM t_ab1 FULL JOIN t_ab2 ON (t_ab1.a == t_ab2.a AND t_ab1.b == t_ab2.b) ORDER BY ifNull(t_ab1.id, t_ab2.id);
SELECT '= left =';
SELECT a, b, t_ab2.a, t_ab2.b FROM t_ab1 LEFT JOIN t_ab2 ON (t_ab1.a == t_ab2.a AND t_ab1.b == t_ab2.b) ORDER BY ifNull(t_ab1.id, t_ab2.id);
SELECT '= right =';
SELECT a, b, t_ab2.a, t_ab2.b FROM t_ab1 RIGHT JOIN t_ab2 ON (t_ab1.a == t_ab2.a AND t_ab1.b == t_ab2.b) ORDER BY ifNull(t_ab1.id, t_ab2.id);
SELECT '= inner =';
SELECT a, b, t_ab2.a, t_ab2.b FROM t_ab1 INNER JOIN t_ab2 ON (t_ab1.a == t_ab2.a AND t_ab1.b == t_ab2.b) ORDER BY ifNull(t_ab1.id, t_ab2.id);
SELECT '= agg =';
SELECT sum(a), sum(b) FROM t_ab1 FULL JOIN t_ab2 USING (a, b);
SELECT sum(a), sum(b) FROM t_ab1 LEFT JOIN t_ab2 USING (a, b);
SELECT sum(a), sum(b) FROM t_ab1 RIGHT JOIN t_ab2 USING (a, b);
SELECT sum(a), sum(b) FROM t_ab1 INNER JOIN t_ab2 USING (a, b);
SELECT '- types -';
SELECT sum(a) + sum(t_ab2.a) - 1, sum(b) + sum(t_ab2.b) - 1 FROM t_ab1 FULL JOIN t_ab2 ON (t_ab1.a == t_ab2.a AND t_ab1.b == t_ab2.b);
SELECT sum(a) + sum(t_ab2.a) - 1, sum(b) + sum(t_ab2.b) - 1 FROM t_ab1 LEFT JOIN t_ab2 ON (t_ab1.a == t_ab2.a AND t_ab1.b == t_ab2.b);
SELECT sum(a) + sum(t_ab2.a) - 1, sum(b) + sum(t_ab2.b) - 1 FROM t_ab1 RIGHT JOIN t_ab2 ON (t_ab1.a == t_ab2.a AND t_ab1.b == t_ab2.b);
SELECT sum(a) + sum(t_ab2.a) - 1, sum(b) + sum(t_ab2.b) - 1 FROM t_ab1 INNER JOIN t_ab2 ON (t_ab1.a == t_ab2.a AND t_ab1.b == t_ab2.b);
SELECT '= types =';
SELECT any(toTypeName(a)) == 'Int32' AND any(toTypeName(b)) == 'Nullable(Int64)' FROM t_ab1 FULL JOIN t_ab2 USING (a, b);
SELECT any(toTypeName(a)) == 'Int32' AND any(toTypeName(b)) == 'Nullable(Int64)' FROM t_ab1 LEFT JOIN t_ab2 USING (a, b);
SELECT any(toTypeName(a)) == 'Int32' AND any(toTypeName(b)) == 'Nullable(Int64)' FROM t_ab1 RIGHT JOIN t_ab2 USING (a, b);
SELECT any(toTypeName(a)) == 'Int32' AND any(toTypeName(b)) == 'Nullable(Int64)' FROM t_ab1 INNER JOIN t_ab2 USING (a, b);
SELECT '--- partial_merge ---';
SELECT '=== partial_merge ===';
SET join_algorithm = 'partial_merge';
SELECT '- full -';
SELECT '= full =';
SELECT a, b FROM t_ab1 FULL JOIN t_ab2 USING (a, b) ORDER BY ifNull(t_ab1.id, t_ab2.id);
SELECT '- left -';
SELECT '= left =';
SELECT a, b FROM t_ab1 LEFT JOIN t_ab2 USING (a, b) ORDER BY ifNull(t_ab1.id, t_ab2.id);
SELECT '- right -';
SELECT '= right =';
SELECT a, b FROM t_ab1 RIGHT JOIN t_ab2 USING (a, b) ORDER BY ifNull(t_ab1.id, t_ab2.id);
SELECT '- inner -';
SELECT '= inner =';
SELECT a, b FROM t_ab1 INNER JOIN t_ab2 USING (a, b) ORDER BY ifNull(t_ab1.id, t_ab2.id);
SELECT '- agg -';
SELECT '= full =';
SELECT a, b, t_ab2.a, t_ab2.b FROM t_ab1 FULL JOIN t_ab2 ON (t_ab1.a == t_ab2.a AND t_ab1.b == t_ab2.b) ORDER BY ifNull(t_ab1.id, t_ab2.id);
SELECT '= left =';
SELECT a, b, t_ab2.a, t_ab2.b FROM t_ab1 LEFT JOIN t_ab2 ON (t_ab1.a == t_ab2.a AND t_ab1.b == t_ab2.b) ORDER BY ifNull(t_ab1.id, t_ab2.id);
SELECT '= right =';
SELECT a, b, t_ab2.a, t_ab2.b FROM t_ab1 RIGHT JOIN t_ab2 ON (t_ab1.a == t_ab2.a AND t_ab1.b == t_ab2.b) ORDER BY ifNull(t_ab1.id, t_ab2.id);
SELECT '= inner =';
SELECT a, b, t_ab2.a, t_ab2.b FROM t_ab1 INNER JOIN t_ab2 ON (t_ab1.a == t_ab2.a AND t_ab1.b == t_ab2.b) ORDER BY ifNull(t_ab1.id, t_ab2.id);
SELECT '= agg =';
SELECT sum(a), sum(b) FROM t_ab1 FULL JOIN t_ab2 USING (a, b);
SELECT sum(a), sum(b) FROM t_ab1 LEFT JOIN t_ab2 USING (a, b);
SELECT sum(a), sum(b) FROM t_ab1 RIGHT JOIN t_ab2 USING (a, b);
SELECT sum(a), sum(b) FROM t_ab1 INNER JOIN t_ab2 USING (a, b);
SELECT '- types -';
SELECT sum(a) + sum(t_ab2.a) - 1, sum(b) + sum(t_ab2.b) - 1 FROM t_ab1 FULL JOIN t_ab2 ON (t_ab1.a == t_ab2.a AND t_ab1.b == t_ab2.b);
SELECT sum(a) + sum(t_ab2.a) - 1, sum(b) + sum(t_ab2.b) - 1 FROM t_ab1 LEFT JOIN t_ab2 ON (t_ab1.a == t_ab2.a AND t_ab1.b == t_ab2.b);
SELECT sum(a) + sum(t_ab2.a) - 1, sum(b) + sum(t_ab2.b) - 1 FROM t_ab1 RIGHT JOIN t_ab2 ON (t_ab1.a == t_ab2.a AND t_ab1.b == t_ab2.b);
SELECT sum(a) + sum(t_ab2.a) - 1, sum(b) + sum(t_ab2.b) - 1 FROM t_ab1 INNER JOIN t_ab2 ON (t_ab1.a == t_ab2.a AND t_ab1.b == t_ab2.b);
SELECT '= types =';
SELECT any(toTypeName(a)) == 'Int32' AND any(toTypeName(b)) == 'Nullable(Int64)' FROM t_ab1 FULL JOIN t_ab2 USING (a, b);
SELECT any(toTypeName(a)) == 'Int32' AND any(toTypeName(b)) == 'Nullable(Int64)' FROM t_ab1 LEFT JOIN t_ab2 USING (a, b);