From cd7d9584bdd06fe92e2ea567bc4004516af3231a Mon Sep 17 00:00:00 2001 From: vdimir Date: Wed, 17 Feb 2021 17:19:30 +0300 Subject: [PATCH] Add tests to 01720_join_implicit_cast - switch, use_nulls --- ...nce => 01720_join_implicit_cast.reference} | 130 ++++++++++++++++++ ..._cast.sql => 01720_join_implicit_cast.sql} | 63 +++++++++ 2 files changed, 193 insertions(+) rename tests/queries/0_stateless/{01686_join_implicit_cast.reference => 01720_join_implicit_cast.reference} (63%) rename tests/queries/0_stateless/{01686_join_implicit_cast.sql => 01720_join_implicit_cast.sql} (75%) diff --git a/tests/queries/0_stateless/01686_join_implicit_cast.reference b/tests/queries/0_stateless/01720_join_implicit_cast.reference similarity index 63% rename from tests/queries/0_stateless/01686_join_implicit_cast.reference rename to tests/queries/0_stateless/01720_join_implicit_cast.reference index 517b356e519..21b02c112d9 100644 --- a/tests/queries/0_stateless/01686_join_implicit_cast.reference +++ b/tests/queries/0_stateless/01720_join_implicit_cast.reference @@ -200,6 +200,136 @@ 1 1 1 +--- switch --- +- full - +-4 0 196 +-3 0 197 +-2 0 198 +-1 0 199 +0 0 200 +1 101 201 +2 102 202 +3 103 203 +4 104 204 +5 105 205 +6 106 \N +7 107 \N +8 108 \N +9 109 \N +10 110 \N +- left - +1 101 201 +2 102 202 +3 103 203 +4 104 204 +5 105 205 +6 106 \N +7 107 \N +8 108 \N +9 109 \N +10 110 \N +- right - +-4 0 196 +-3 0 197 +-2 0 198 +-1 0 199 +0 0 200 +1 101 201 +2 102 202 +3 103 203 +4 104 204 +5 105 205 +- inner - +1 101 201 +2 102 202 +3 103 203 +4 104 204 +5 105 205 +- full - +0 0 -4 +0 0 -3 +0 0 -2 +0 0 -1 +0 0 0 +1 1 1 +2 2 2 +3 3 3 +4 4 4 +5 5 5 +6 6 0 +7 7 0 +8 8 0 +9 9 0 +10 10 0 +- left - +1 1 1 +2 2 2 +3 3 3 +4 4 4 +5 5 5 +6 6 0 +7 7 0 +8 8 0 +9 9 0 +10 10 0 +- right - +0 0 -4 +0 0 -3 +0 0 -2 +0 0 -1 +0 0 0 +1 1 1 +2 2 2 +3 3 3 +4 4 4 +5 5 5 +- inner - +1 1 1 +2 2 2 +3 3 3 +4 4 4 +5 5 5 +- agg - +1 +1 +1 +1 +- types - +1 +1 +1 +1 +1 +1 +--- join use nulls --- +- full - +-4 \N 196 +-3 \N 197 +-2 \N 198 +-1 \N 199 +0 \N 200 +1 101 201 +2 102 202 +3 103 203 +4 104 204 +5 105 205 +6 106 \N +7 107 \N +8 108 \N +9 109 \N +10 110 \N +- right - +-4 \N 196 +-3 \N 197 +-2 \N 198 +-1 \N 199 +0 \N 200 +1 101 201 +2 102 202 +3 103 203 +4 104 204 +5 105 205 +--- --- hash --- - full - 1 1 diff --git a/tests/queries/0_stateless/01686_join_implicit_cast.sql b/tests/queries/0_stateless/01720_join_implicit_cast.sql similarity index 75% rename from tests/queries/0_stateless/01686_join_implicit_cast.sql rename to tests/queries/0_stateless/01720_join_implicit_cast.sql index f4c10e6517d..b2fa227f0d5 100644 --- a/tests/queries/0_stateless/01686_join_implicit_cast.sql +++ b/tests/queries/0_stateless/01720_join_implicit_cast.sql @@ -94,9 +94,70 @@ SELECT * FROM t1 LEFT JOIN t2 ON(t1.a == t2.a) ORDER BY (a); -- { serverError 53 SELECT * FROM t1 RIGHT JOIN t2 ON (t1.a == t2.a) ORDER BY (a); -- { serverError 53 } SELECT * FROM t1 INNER JOIN t2 ON (t1.a == t2.a) ORDER BY (a); -- { serverError 53 } + +SELECT '--- switch ---'; + +SET join_algorithm = 'auto'; +SET max_bytes_in_join = 100; + +SELECT '- full -'; +SELECT a, b, t2.b FROM t1 FULL JOIN t2 USING (a) ORDER BY (a); +SELECT '- left -'; +SELECT a, b, t2.b FROM t1 LEFT JOIN t2 USING (a) ORDER BY (a); +SELECT '- right -'; +SELECT a, b, t2.b FROM t1 RIGHT JOIN t2 USING (a) ORDER BY (a); +SELECT '- inner -'; +SELECT a, b, t2.b FROM t1 INNER JOIN t2 USING (a) ORDER BY (a); + + +SELECT '- full -'; +SELECT a, t1.a, t2.a FROM t1 FULL JOIN t2 USING (a) ORDER BY (t1.a, t2.a); +SELECT '- left -'; +SELECT a, t1.a, t2.a FROM t1 LEFT JOIN t2 USING (a) ORDER BY (t1.a, t2.a); +SELECT '- right -'; +SELECT a, t1.a, t2.a FROM t1 RIGHT JOIN t2 USING (a) ORDER BY (t1.a, t2.a); +SELECT '- inner -'; +SELECT a, t1.a, t2.a FROM t1 INNER JOIN t2 USING (a) ORDER BY (t1.a, t2.a); + +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 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); +SELECT any(toTypeName(a)) == 'Int32' AND any(toTypeName(t2.a)) == 'Int32' FROM t1 INNER JOIN t2 USING (a); + +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 * FROM t1 FULL JOIN t2 ON (t1.a == t2.a) ORDER BY (a); -- { serverError 53 } +SELECT * FROM t1 LEFT JOIN t2 ON(t1.a == t2.a) ORDER BY (a); -- { serverError 53 } +SELECT * FROM t1 RIGHT JOIN t2 ON (t1.a == t2.a) ORDER BY (a); -- { serverError 53 } +SELECT * FROM t1 INNER JOIN t2 ON (t1.a == t2.a) ORDER BY (a); -- { serverError 53 } + +SET max_bytes_in_join = 0; + +SELECT '--- join use nulls ---'; + +SET join_use_nulls = 1; + +SELECT '- full -'; +SELECT a, b, t2.b FROM t1 FULL JOIN t2 USING (a) ORDER BY (a); +SELECT '- right -'; +SELECT a, b, t2.b FROM t1 RIGHT JOIN t2 USING (a) ORDER BY (a); + +SET join_use_nulls = 0; + DROP TABLE IF EXISTS t1; DROP TABLE IF EXISTS t2; +select '---'; + DROP TABLE IF EXISTS t_ab1; DROP TABLE IF EXISTS t_ab2; @@ -107,6 +168,8 @@ INSERT INTO t_ab2 VALUES (2, -1, 1), (3, 1, NULL), (4, 1, 257), (5, 1, -1), (6, SELECT '--- hash ---'; +SET join_algorithm = 'hash'; + 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 -';