diff --git a/dbms/tests/queries/0_stateless/00874_issue_3495.reference b/dbms/tests/queries/0_stateless/00874_issue_3495.reference new file mode 100644 index 00000000000..ebb020d8e29 --- /dev/null +++ b/dbms/tests/queries/0_stateless/00874_issue_3495.reference @@ -0,0 +1,6 @@ +1 1.1 1.1 +1 1.2 1.1 +2 2.1 2.1 +1 1.1 1.1 +1 1.2 1.1 +2 2.1 2.1 diff --git a/dbms/tests/queries/0_stateless/00874_issue_3495.sql b/dbms/tests/queries/0_stateless/00874_issue_3495.sql new file mode 100644 index 00000000000..02c70ac7482 --- /dev/null +++ b/dbms/tests/queries/0_stateless/00874_issue_3495.sql @@ -0,0 +1,21 @@ +drop table if exists t; +create table t (a Int8, val Float32) engine = Memory(); +insert into t values (1,1.1), (1,1.2), (2,2.1); + +SET enable_optimize_predicate_expression = 0; + +SELECT * FROM ( + SELECT a, t1.val as val1, t2.val as val2 + FROM t t1 + ANY LEFT JOIN t t2 USING a +) ORDER BY val1; + +SET enable_optimize_predicate_expression = 1; + +SELECT * FROM ( + SELECT a, t1.val as val1, t2.val as val2 + FROM t t1 + ANY LEFT JOIN t t2 USING a +) ORDER BY val1; + +drop table t;