2019-10-18 16:34:06 +00:00
|
|
|
SET enable_optimize_predicate_expression = 0;
|
2022-02-11 14:15:56 +00:00
|
|
|
SET optimize_move_to_prewhere = 1;
|
|
|
|
SET convert_query_to_cnf = 0;
|
2019-02-01 16:36:40 +00:00
|
|
|
|
2019-10-17 21:08:28 +00:00
|
|
|
select * from system.one l cross join system.one r;
|
2019-03-05 15:16:59 +00:00
|
|
|
|
2019-06-03 17:36:27 +00:00
|
|
|
DROP TABLE IF EXISTS t1_00826;
|
|
|
|
DROP TABLE IF EXISTS t2_00826;
|
2019-02-01 16:36:40 +00:00
|
|
|
|
2019-06-03 17:36:27 +00:00
|
|
|
CREATE TABLE t1_00826 (a Int8, b Nullable(Int8)) ENGINE = Memory;
|
|
|
|
CREATE TABLE t2_00826 (a Int8, b Nullable(Int8)) ENGINE = Memory;
|
2019-02-01 16:36:40 +00:00
|
|
|
|
2019-06-03 17:36:27 +00:00
|
|
|
INSERT INTO t1_00826 values (1,1), (2,2);
|
|
|
|
INSERT INTO t2_00826 values (1,1), (1,2);
|
|
|
|
INSERT INTO t2_00826 (a) values (2), (3);
|
2019-02-01 16:36:40 +00:00
|
|
|
|
2021-02-19 14:06:57 +00:00
|
|
|
SELECT '--- cross ---';
|
2019-06-03 17:36:27 +00:00
|
|
|
SELECT * FROM t1_00826 cross join t2_00826 where t1_00826.a = t2_00826.a;
|
2021-02-19 14:06:57 +00:00
|
|
|
SELECT '--- cross nullable ---';
|
2019-06-03 17:36:27 +00:00
|
|
|
SELECT * FROM t1_00826 cross join t2_00826 where t1_00826.b = t2_00826.b;
|
2021-02-19 14:06:57 +00:00
|
|
|
SELECT '--- cross nullable vs not nullable ---';
|
2022-06-15 11:25:36 +00:00
|
|
|
SELECT * FROM t1_00826 cross join t2_00826 where t1_00826.a = t2_00826.b ORDER BY t1_00826.a;
|
2021-02-19 14:06:57 +00:00
|
|
|
SELECT '--- cross self ---';
|
2022-06-15 11:25:36 +00:00
|
|
|
SELECT * FROM t1_00826 x cross join t1_00826 y where x.a = y.a and x.b = y.b ORDER BY x.a;
|
2021-02-19 14:06:57 +00:00
|
|
|
SELECT '--- cross one table expr ---';
|
2019-06-03 17:36:27 +00:00
|
|
|
SELECT * FROM t1_00826 cross join t2_00826 where t1_00826.a = t1_00826.b order by (t1_00826.a, t2_00826.a, t2_00826.b);
|
2021-02-19 14:06:57 +00:00
|
|
|
SELECT '--- cross multiple ands ---';
|
2019-06-03 17:36:27 +00:00
|
|
|
SELECT * FROM t1_00826 cross join t2_00826 where t1_00826.a = t2_00826.a and t1_00826.b = t2_00826.b;
|
2021-02-19 14:06:57 +00:00
|
|
|
SELECT '--- cross and inside and ---';
|
2019-06-03 17:36:27 +00:00
|
|
|
SELECT * FROM t1_00826 cross join t2_00826 where t1_00826.a = t2_00826.a and (t1_00826.b = t2_00826.b and 1);
|
2021-02-19 14:06:57 +00:00
|
|
|
SELECT '--- cross split conjunction ---';
|
2019-06-03 17:36:27 +00:00
|
|
|
SELECT * FROM t1_00826 cross join t2_00826 where t1_00826.a = t2_00826.a and t1_00826.b = t2_00826.b and t1_00826.a >= 1 and t2_00826.b = 1;
|
2019-02-01 16:36:40 +00:00
|
|
|
|
2021-02-19 14:06:57 +00:00
|
|
|
SELECT '--- and or ---';
|
|
|
|
SELECT * FROM t1_00826 cross join t2_00826 where t1_00826.a = t2_00826.a and t1_00826.b = t2_00826.b and (t1_00826.a >= 1 OR t2_00826.b = 1);
|
|
|
|
|
|
|
|
SELECT '--- arithmetic expr ---';
|
|
|
|
SELECT * FROM t1_00826 cross join t2_00826 where t1_00826.a + 1 = t2_00826.a + t2_00826.b AND (t1_00826.a + t1_00826.b + t2_00826.a + t2_00826.b > 5);
|
|
|
|
|
|
|
|
SELECT '--- is null or ---';
|
2022-06-15 11:25:36 +00:00
|
|
|
SELECT * FROM t1_00826 cross join t2_00826 where t1_00826.b = t2_00826.a AND (t2_00826.b IS NULL OR t2_00826.b > t2_00826.a) ORDER BY t1_00826.a;
|
2021-02-19 14:06:57 +00:00
|
|
|
|
|
|
|
SELECT '--- do not rewrite alias ---';
|
|
|
|
SELECT a as b FROM t1_00826 cross join t2_00826 where t1_00826.b = t2_00826.a AND b > 0;
|
|
|
|
|
|
|
|
SELECT '--- comma ---';
|
2019-06-03 17:36:27 +00:00
|
|
|
SELECT * FROM t1_00826, t2_00826 where t1_00826.a = t2_00826.a;
|
2021-02-19 14:06:57 +00:00
|
|
|
SELECT '--- comma nullable ---';
|
2019-06-03 17:36:27 +00:00
|
|
|
SELECT * FROM t1_00826, t2_00826 where t1_00826.b = t2_00826.b;
|
2021-02-19 14:06:57 +00:00
|
|
|
SELECT '--- comma and or ---';
|
|
|
|
SELECT * FROM t1_00826, t2_00826 where t1_00826.a = t2_00826.a AND (t2_00826.b IS NULL OR t2_00826.b < 2);
|
2019-02-04 18:45:31 +00:00
|
|
|
|
2019-02-01 16:36:40 +00:00
|
|
|
|
2021-02-19 14:06:57 +00:00
|
|
|
SELECT '--- cross ---';
|
2020-11-02 12:47:12 +00:00
|
|
|
EXPLAIN SYNTAX SELECT * FROM t1_00826 cross join t2_00826 where t1_00826.a = t2_00826.a;
|
2021-02-19 14:06:57 +00:00
|
|
|
SELECT '--- cross nullable ---';
|
2020-11-02 12:47:12 +00:00
|
|
|
EXPLAIN SYNTAX SELECT * FROM t1_00826, t2_00826 where t1_00826.a = t2_00826.a;
|
2021-02-19 14:06:57 +00:00
|
|
|
SELECT '--- cross nullable vs not nullable ---';
|
2020-11-02 12:47:12 +00:00
|
|
|
EXPLAIN SYNTAX SELECT * FROM t1_00826 cross join t2_00826 where t1_00826.a = t2_00826.b;
|
2021-02-19 14:06:57 +00:00
|
|
|
SELECT '--- cross self ---';
|
2020-11-02 12:47:12 +00:00
|
|
|
EXPLAIN SYNTAX SELECT * FROM t1_00826 x cross join t1_00826 y where x.a = y.a and x.b = y.b;
|
2021-02-19 14:06:57 +00:00
|
|
|
SELECT '--- cross one table expr ---';
|
2020-11-02 12:47:12 +00:00
|
|
|
EXPLAIN SYNTAX SELECT * FROM t1_00826 cross join t2_00826 where t1_00826.a = t1_00826.b;
|
2021-02-19 14:06:57 +00:00
|
|
|
SELECT '--- cross multiple ands ---';
|
2020-11-02 12:47:12 +00:00
|
|
|
EXPLAIN SYNTAX SELECT * FROM t1_00826 cross join t2_00826 where t1_00826.a = t2_00826.a and t1_00826.b = t2_00826.b;
|
2021-02-19 14:06:57 +00:00
|
|
|
SELECT '--- cross and inside and ---';
|
2020-11-02 12:47:12 +00:00
|
|
|
EXPLAIN SYNTAX SELECT * FROM t1_00826 cross join t2_00826 where t1_00826.a = t2_00826.a and (t1_00826.a = t2_00826.a and (t1_00826.a = t2_00826.a and t1_00826.b = t2_00826.b));
|
2019-02-01 16:36:40 +00:00
|
|
|
|
2021-02-19 14:06:57 +00:00
|
|
|
SELECT '--- cross split conjunction ---';
|
2020-11-02 12:47:12 +00:00
|
|
|
EXPLAIN SYNTAX SELECT * FROM t1_00826 cross join t2_00826 where t1_00826.a = t2_00826.a and t1_00826.b = t2_00826.b and t1_00826.a >= 1 and t2_00826.b > 0;
|
2019-02-01 17:22:28 +00:00
|
|
|
|
2021-02-19 14:06:57 +00:00
|
|
|
SELECT '--- and or ---';
|
|
|
|
EXPLAIN SYNTAX SELECT * FROM t1_00826 cross join t2_00826 where t1_00826.a = t2_00826.a and t1_00826.b = t2_00826.b and (t1_00826.a >= 1 OR t2_00826.b = 1);
|
|
|
|
|
|
|
|
SELECT '--- arithmetic expr ---';
|
|
|
|
EXPLAIN SYNTAX SELECT * FROM t1_00826 cross join t2_00826 where t1_00826.a + 1 = t2_00826.a + t2_00826.b AND (t1_00826.a + t1_00826.b + t2_00826.a + t2_00826.b > 5);
|
|
|
|
|
|
|
|
SELECT '--- is null or ---';
|
|
|
|
EXPLAIN SYNTAX SELECT * FROM t1_00826 cross join t2_00826 where t1_00826.b = t2_00826.a AND (t2_00826.b IS NULL OR t2_00826.b > t2_00826.a);
|
|
|
|
|
|
|
|
SELECT '--- do not rewrite alias ---';
|
|
|
|
EXPLAIN SYNTAX SELECT a as b FROM t1_00826 cross join t2_00826 where t1_00826.b = t2_00826.a AND b > 0;
|
|
|
|
|
|
|
|
SELECT '--- comma ---';
|
|
|
|
EXPLAIN SYNTAX SELECT * FROM t1_00826, t2_00826 where t1_00826.a = t2_00826.a;
|
|
|
|
SELECT '--- comma nullable ---';
|
|
|
|
EXPLAIN SYNTAX SELECT * FROM t1_00826, t2_00826 where t1_00826.b = t2_00826.b;
|
|
|
|
SELECT '--- comma and or ---';
|
|
|
|
EXPLAIN SYNTAX SELECT * FROM t1_00826, t2_00826 where t1_00826.a = t2_00826.a AND (t2_00826.b IS NULL OR t2_00826.b < 2);
|
|
|
|
|
2019-06-03 17:36:27 +00:00
|
|
|
DROP TABLE t1_00826;
|
|
|
|
DROP TABLE t2_00826;
|