提交 554e4ab5 编写于 作者: C chertus

fix cross alliasing case with JOIN ON

上级 06076e67
......@@ -110,6 +110,9 @@ private:
static const ASTIdentifier * unrollAliases(const ASTIdentifier * identifier, const Aliases & aliases)
{
if (identifier->compound())
return identifier;
UInt32 max_attempts = 100;
for (auto it = aliases.find(identifier->name); it != aliases.end();)
{
......
......@@ -12,6 +12,12 @@ y y
y y
y y
y y
2 2
2 2
2 2
2 2
2 2
2 2
2 y 2 w
2 y 2 w
2 2
......@@ -26,3 +32,9 @@ y y
y y
y y
y y
2 2
2 2
2 2
2 2
2 2
2 2
......@@ -10,6 +10,7 @@ insert into t1 values (1, 'x'), (2, 'y'), (3, 'z');
insert into t2 values (2, 'w'), (4, 'y');
set enable_optimize_predicate_expression = 0;
select * from t1 join t2 on a = c;
select * from t1 join t2 on c = a;
......@@ -28,14 +29,13 @@ select b as a, d as c from t1 join t2 on c = a;
select b as c, d as a from t1 join t2 on a = c;
select b as c, d as a from t1 join t2 on c = a;
-- TODO
-- select t1.a as a, t2.c as c from t1 join t2 on a = c;
-- select t1.a as a, t2.c as c from t1 join t2 on c = a;
-- select t1.a as c, t2.c as a from t1 join t2 on a = c;
-- select t1.a as c, t2.c as a from t1 join t2 on c = a;
--
-- select t1.a as c, t2.c as a from t1 join t2 on t1.a = t2.c;
-- select t1.a as c, t2.c as a from t1 join t2 on t2.c = t1.a;
select t1.a as a, t2.c as c from t1 join t2 on a = c;
select t1.a as a, t2.c as c from t1 join t2 on c = a;
select t1.a as c, t2.c as a from t1 join t2 on a = c;
select t1.a as c, t2.c as a from t1 join t2 on c = a;
select t1.a as c, t2.c as a from t1 join t2 on t1.a = t2.c;
select t1.a as c, t2.c as a from t1 join t2 on t2.c = t1.a;
set enable_optimize_predicate_expression = 1;
......@@ -57,5 +57,13 @@ select b as a, d as c from t1 join t2 on c = a;
select b as c, d as a from t1 join t2 on a = c;
select b as c, d as a from t1 join t2 on c = a;
select t1.a as a, t2.c as c from t1 join t2 on a = c;
select t1.a as a, t2.c as c from t1 join t2 on c = a;
select t1.a as c, t2.c as a from t1 join t2 on a = c;
select t1.a as c, t2.c as a from t1 join t2 on c = a;
select t1.a as c, t2.c as a from t1 join t2 on t1.a = t2.c;
select t1.a as c, t2.c as a from t1 join t2 on t2.c = t1.a;
drop table t1;
drop table t2;
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册