2019-03-04 19:40:58 +00:00
|
|
|
drop table if exists t;
|
|
|
|
drop table if exists s;
|
|
|
|
drop table if exists y;
|
|
|
|
|
|
|
|
create table t(a Int64, b Int64) engine = TinyLog;
|
|
|
|
create table s(a Int64, b Int64) engine = TinyLog;
|
|
|
|
create table y(a Int64, b Int64) engine = TinyLog;
|
|
|
|
|
|
|
|
insert into t values (1,1), (2,2);
|
|
|
|
insert into s values (1,1);
|
|
|
|
insert into y values (1,1);
|
|
|
|
|
|
|
|
select t.a, s.b, s.a, s.b, y.a, y.b from t
|
|
|
|
left join s on (t.a = s.a and t.b = s.b)
|
2019-09-23 13:55:04 +00:00
|
|
|
left join y on (y.a = s.a and y.b = s.b)
|
|
|
|
order by t.a
|
|
|
|
format Vertical;
|
2019-03-04 19:40:58 +00:00
|
|
|
|
|
|
|
select t.a, s.b, s.a, s.b, y.a, y.b from t
|
|
|
|
left join s on (t.a = s.a and s.b = t.b)
|
2019-09-20 16:01:19 +00:00
|
|
|
left join y on (y.a = s.a and y.b = s.b)
|
|
|
|
order by t.a
|
|
|
|
format PrettyCompactNoEscapes;
|
2019-03-04 19:40:58 +00:00
|
|
|
|
|
|
|
select t.a as t_a from t
|
2019-09-20 16:01:19 +00:00
|
|
|
left join s on s.a = t_a
|
|
|
|
order by t.a
|
|
|
|
format PrettyCompactNoEscapes;
|
2019-03-04 19:40:58 +00:00
|
|
|
|
|
|
|
select t.a, s.a as s_a from t
|
|
|
|
left join s on s.a = t.a
|
2019-09-20 16:01:19 +00:00
|
|
|
left join y on y.b = s.b
|
|
|
|
order by t.a
|
|
|
|
format PrettyCompactNoEscapes;
|
2019-03-04 19:40:58 +00:00
|
|
|
|
|
|
|
select t.a, t.a, t.b as t_b from t
|
2019-03-05 12:34:48 +00:00
|
|
|
left join s on t.a = s.a
|
2019-09-20 16:01:19 +00:00
|
|
|
left join y on y.b = s.b
|
|
|
|
order by t.a
|
|
|
|
format PrettyCompactNoEscapes;
|
2019-03-04 19:40:58 +00:00
|
|
|
|
2020-03-20 19:18:42 +00:00
|
|
|
set multiple_joins_rewriter_version = 1;
|
|
|
|
|
|
|
|
select s.a, s.a, s.b as s_b, s.b from t
|
|
|
|
left join s on s.a = t.a
|
|
|
|
left join y on s.b = y.b
|
|
|
|
order by t.a
|
|
|
|
format PrettyCompactNoEscapes;
|
|
|
|
|
|
|
|
select y.a, y.a, y.b as y_b, y.b from t
|
|
|
|
left join s on s.a = t.a
|
|
|
|
left join y on y.b = s.b
|
|
|
|
order by t.a
|
|
|
|
format PrettyCompactNoEscapes;
|
|
|
|
|
|
|
|
select t.a, t.a as t_a, s.a, s.a as s_a, y.a, y.a as y_a from t
|
|
|
|
left join s on t.a = s.a
|
|
|
|
left join y on y.b = s.b
|
|
|
|
order by t.a
|
|
|
|
format PrettyCompactNoEscapes;
|
|
|
|
|
|
|
|
set multiple_joins_rewriter_version = 2;
|
|
|
|
|
2019-03-05 12:34:48 +00:00
|
|
|
select s.a, s.a, s.b as s_b, s.b from t
|
2019-03-04 19:40:58 +00:00
|
|
|
left join s on s.a = t.a
|
2019-09-20 16:01:19 +00:00
|
|
|
left join y on s.b = y.b
|
|
|
|
order by t.a
|
|
|
|
format PrettyCompactNoEscapes;
|
2019-03-04 19:40:58 +00:00
|
|
|
|
2019-03-05 12:34:48 +00:00
|
|
|
select y.a, y.a, y.b as y_b, y.b from t
|
|
|
|
left join s on s.a = t.a
|
2019-09-20 16:01:19 +00:00
|
|
|
left join y on y.b = s.b
|
|
|
|
order by t.a
|
|
|
|
format PrettyCompactNoEscapes;
|
2019-03-04 19:40:58 +00:00
|
|
|
|
2019-03-05 12:34:48 +00:00
|
|
|
select t.a, t.a as t_a, s.a, s.a as s_a, y.a, y.a as y_a from t
|
|
|
|
left join s on t.a = s.a
|
2019-09-20 16:01:19 +00:00
|
|
|
left join y on y.b = s.b
|
|
|
|
order by t.a
|
|
|
|
format PrettyCompactNoEscapes;
|
2019-03-04 19:40:58 +00:00
|
|
|
|
|
|
|
drop table t;
|
|
|
|
drop table s;
|
|
|
|
drop table y;
|