@@ -809,40 +809,27 @@ TEST_F(OptimizerSQLTests, NestedQueryInHavingTest) {
809
809
TestingSQLUtil::ExecuteSQLQuery (" INSERT INTO test2 VALUES (22, 00, '4th');" );
810
810
811
811
TestingSQLUtil::ExecuteSQLQuery (" CREATE TABLE agg(a int, b int);" );
812
- TestingSQLUtil::ExecuteSQLQuery (" INSERT INTO agg VALUES (1, 2 );" );
813
- TestingSQLUtil::ExecuteSQLQuery (" INSERT INTO agg VALUES (1, 3 );" );
814
- TestingSQLUtil::ExecuteSQLQuery (" INSERT INTO agg VALUES (2, 3 );" );
815
- TestingSQLUtil::ExecuteSQLQuery (" INSERT INTO agg VALUES (2, 4 );" );
812
+ TestingSQLUtil::ExecuteSQLQuery (" INSERT INTO agg VALUES (1, 22 );" );
813
+ TestingSQLUtil::ExecuteSQLQuery (" INSERT INTO agg VALUES (2, 33 );" );
814
+ TestingSQLUtil::ExecuteSQLQuery (" INSERT INTO agg VALUES (1, 11 );" );
815
+ TestingSQLUtil::ExecuteSQLQuery (" INSERT INTO agg VALUES (1, 11 );" );
816
816
TestUtil (
817
817
" select sum(a) as c, b from test as B group by b having exists (select b "
818
818
" from test2 where a = B.b);" ,
819
819
{" 7" , " 11" , " 8" , " 22" }, false );
820
+ // TestUtil(
821
+ // "select sum(a) as d, b from test as B group by b having exists (select
822
+ // b "
823
+ // "from test2 where a = B.d);",
824
+ // {"7", "11", "8", "22"}, false);
820
825
TestUtil (
821
- " select sum(a) as c, b from test as B group by b having exists (select b "
822
- " from test2 where a = B.c);" ,
826
+ " select sum(a) as c, b from test as B group by b having exists (select "
827
+ " avg(a) from agg where b = B.b);" ,
828
+ {" 7" , " 11" , " 8" , " 22" , " 3" , " 33" }, false );
829
+ TestUtil (
830
+ " select sum(a) as c, b from test as B group by b having exists (select "
831
+ " avg(a) from agg where b = B.b group by b having avg(a) < 2);" ,
823
832
{" 7" , " 11" , " 8" , " 22" }, false );
824
- // TestUtil(
825
- // "select b from test where a in (select a from test as t where a = "
826
- // "test.a)",
827
- // {"11", "22", "33", "0"}, false);
828
- // TestUtil(
829
- // "select B.a from test as B where exists (select b as a from test2 where "
830
- // "a = B.a) and "
831
- // "b in (select b from test where b > 22);",
832
- // {"3"}, false);
833
- // TestUtil(
834
- // "select B.a from test as B where exists (select b as a from test2 where "
835
- // "a = B.a) and "
836
- // "b in (select b from test) and c > 0;",
837
- // {"1", "3"}, false);
838
- // TestUtil(
839
- // "select t1.a, t2.a from test as t1 join test as t2 on t1.a=t2.a "
840
- // "where t1.b+t2.b in (select 2*b from test2 where a > 2)",
841
- // {"3", "3", "4", "4"}, false);
842
- // TestUtil(
843
- // "select B.a from test as B where exists (select b as a from test as T "
844
- // "where a = B.a and exists (select c from test where T.c = c));",
845
- // {"1", "2", "3", "4"}, false);
846
833
}
847
834
848
835
} // namespace test
0 commit comments