diff --git a/dbcon/mysql/ha_scalar_sub.cpp b/dbcon/mysql/ha_scalar_sub.cpp index b12ea4791..34afa4aea 100644 --- a/dbcon/mysql/ha_scalar_sub.cpp +++ b/dbcon/mysql/ha_scalar_sub.cpp @@ -275,34 +275,6 @@ execplan::ParseTree* ScalarSub::buildParseTree(PredicateOperator* op) fGwip.subselectList.push_back(csep); - // error out non-support case for now: comparison out of semi join tables. - // only check for simplecolumn - if (!gwi.correlatedTbNameVec.empty()) - { - for (uint32_t i = 0; i < cols.size(); i++) - { - SimpleColumn* sc = dynamic_cast(cols[i].get()); - - if (sc) - { - CalpontSystemCatalog::TableAliasName tan = - make_aliastable(sc->schemaName(), sc->tableName(), sc->tableAlias()); - uint32_t j = 0; - - for (; j < gwi.correlatedTbNameVec.size(); j++) - if (tan == gwi.correlatedTbNameVec[j]) - break; - - if (j == gwi.correlatedTbNameVec.size()) - { - fGwip.fatalParseError = true; - fGwip.parseErrorText = IDBErrorInfo::instance()->errorMsg(ERR_NON_SUPPORT_SCALAR); - return NULL; - } - } - } - } - // remove outer query tables CalpontSelectExecutionPlan::TableList tblist; diff --git a/mysql-test/columnstore/basic/r/mcol-5195.result b/mysql-test/columnstore/basic/r/mcol-5195.result new file mode 100644 index 000000000..dceb428e0 --- /dev/null +++ b/mysql-test/columnstore/basic/r/mcol-5195.result @@ -0,0 +1,58 @@ +DROP DATABASE IF EXISTS mcol5195; +CREATE DATABASE mcol5195; +USE mcol5195; +create table t1 (a int, b int) engine=columnstore; +create table t2 (a int, b int) engine=columnstore; +insert into t1 values (1, 2), (1, 3), (1, 4), (2, 5), (2, 6), (2, 7); +insert into t2 values (1, 2), (1, 2), (1, 4), (2, 5), (2, 6), (2, 8); +select * from t1, t2 where t1.a = t2.a and t2.b = (select max(b) from t2 where t1.a = t2.a) order by t2.b; +a b a b +1 4 1 4 +1 2 1 4 +1 3 1 4 +2 7 2 8 +2 5 2 8 +2 6 2 8 +select * from t1, t2 where t1.a = t2.a and t2.b < (select max(b) from t2 where t1.a = t2.a) order by t2.b; +a b a b +1 3 1 2 +1 4 1 2 +1 2 1 2 +1 4 1 2 +1 2 1 2 +1 3 1 2 +2 6 2 5 +2 5 2 5 +2 7 2 5 +2 5 2 6 +2 6 2 6 +2 7 2 6 +select * from t1, t2 where t1.a = t2.a and t2.b > (select max(b) from t2 where t1.a = t2.a) order by t2.b; +a b a b +select * from t1, t2 where t1.a = t2.a and t1.b = (select avg(t2.b) from t2 where t1.a = t2.a group by t2.a) order by t2.b; +a b a b +select * from t1, t2 where t1.a = t2.a and t2.b < (select avg(t2.b) from t2 where t1.a = t2.a group by t2.a) order by t2.b; +a b a b +1 3 1 2 +1 4 1 2 +1 2 1 2 +1 4 1 2 +1 2 1 2 +1 3 1 2 +2 6 2 5 +2 5 2 5 +2 7 2 5 +2 5 2 6 +2 6 2 6 +2 7 2 6 +select * from t1, t2 where t1.a = t2.a and t2.b > (select avg(t2.b) from t2 where t1.a = t2.a group by t2.a) order by t2.b; +a b a b +1 4 1 4 +1 2 1 4 +1 3 1 4 +2 7 2 8 +2 5 2 8 +2 6 2 8 +drop table t1; +drop table t2; +DROP DATABASE mcol5195; diff --git a/mysql-test/columnstore/basic/t/mcol-5195.test b/mysql-test/columnstore/basic/t/mcol-5195.test new file mode 100644 index 000000000..2012a6101 --- /dev/null +++ b/mysql-test/columnstore/basic/t/mcol-5195.test @@ -0,0 +1,28 @@ + +#-- source ../include/have_innodb.inc + +--disable_warnings +DROP DATABASE IF EXISTS mcol5195; +--enable_warnings + +CREATE DATABASE mcol5195; + +USE mcol5195; + +create table t1 (a int, b int) engine=columnstore; +create table t2 (a int, b int) engine=columnstore; + +insert into t1 values (1, 2), (1, 3), (1, 4), (2, 5), (2, 6), (2, 7); +insert into t2 values (1, 2), (1, 2), (1, 4), (2, 5), (2, 6), (2, 8); + +select * from t1, t2 where t1.a = t2.a and t2.b = (select max(b) from t2 where t1.a = t2.a) order by t2.b; +select * from t1, t2 where t1.a = t2.a and t2.b < (select max(b) from t2 where t1.a = t2.a) order by t2.b; +select * from t1, t2 where t1.a = t2.a and t2.b > (select max(b) from t2 where t1.a = t2.a) order by t2.b; + +select * from t1, t2 where t1.a = t2.a and t1.b = (select avg(t2.b) from t2 where t1.a = t2.a group by t2.a) order by t2.b; +select * from t1, t2 where t1.a = t2.a and t2.b < (select avg(t2.b) from t2 where t1.a = t2.a group by t2.a) order by t2.b; +select * from t1, t2 where t1.a = t2.a and t2.b > (select avg(t2.b) from t2 where t1.a = t2.a group by t2.a) order by t2.b; + +drop table t1; +drop table t2; +DROP DATABASE mcol5195;