diff --git a/src/sql/optimizer/ob_logical_operator.cpp b/src/sql/optimizer/ob_logical_operator.cpp index 82bcda82dd..85d47be917 100644 --- a/src/sql/optimizer/ob_logical_operator.cpp +++ b/src/sql/optimizer/ob_logical_operator.cpp @@ -1548,6 +1548,8 @@ int ObLogicalOperator::allocate_expr_pre(ObAllocExprContext &ctx) LOG_WARN("failed to extract const exprs", K(ret)); } else if (OB_FAIL(add_exprs_to_ctx(ctx, op_exprs_))) { LOG_WARN("failed to add exprs to ctx", K(ret)); + } else if (OB_FAIL(force_pushdown_exprs(ctx))) { + LOG_WARN("failed to pushdown exprs", K(ret)); } else { LOG_TRACE("succeed to allocate expr pre", K(id_), K(op_exprs_.count()), K(op_exprs_), K(get_name()), K(is_plan_root())); @@ -1902,6 +1904,40 @@ int ObLogicalOperator::find_consumer_id_for_shared_expr(const ObIArray exprs; + uint64_t producer_id = OB_INVALID_ID; + if (OB_FAIL(static_cast(this)->get_sort_exprs(exprs))) { + LOG_WARN("failed to get sort exprs", K(ret)); + } else if (OB_FAIL(get_pushdown_producer_id(producer_id))) { + LOG_WARN("failed to get pushdown producer id", K(ret)); + } else if (OB_INVALID_ID == producer_id) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unable to get pushdown producer id", K(producer_id), K(ret)); + } else if (OB_FAIL(add_exprs_to_ctx(ctx, exprs, producer_id))) { + LOG_WARN("failed to add exprs to ctx"); + } + } + return ret; +} + +int ObLogicalOperator::get_pushdown_producer_id(uint64_t &producer_id) +{ + int ret = OB_SUCCESS; + ObLogicalOperator *child = NULL; + if (OB_ISNULL(child = get_child(ObLogicalOperator::first_child))) { + // do nothing + } else if (OB_FAIL(get_next_producer_id(child, producer_id))) { + LOG_WARN("failed to get next producer id", K(ret)); + } + return ret; +} + int ObLogicalOperator::allocate_expr_post(ObAllocExprContext &ctx) { int ret = OB_SUCCESS; diff --git a/src/sql/optimizer/ob_logical_operator.h b/src/sql/optimizer/ob_logical_operator.h index c2f1a6ae8c..42a4d8e485 100644 --- a/src/sql/optimizer/ob_logical_operator.h +++ b/src/sql/optimizer/ob_logical_operator.h @@ -1195,6 +1195,8 @@ public: int extract_non_const_exprs(const ObIArray &input_exprs, ObIArray &non_const_exprs); + int force_pushdown_exprs(ObAllocExprContext &ctx); + int get_pushdown_producer_id(uint64_t &producer_id); int extract_shared_exprs(const ObIArray &exprs, ObAllocExprContext &ctx, diff --git a/tools/deploy/mysql_test/test_suite/join/r/mysql/join_merge.result b/tools/deploy/mysql_test/test_suite/join/r/mysql/join_merge.result index 234062be3b..3f995ac12a 100644 --- a/tools/deploy/mysql_test/test_suite/join/r/mysql/join_merge.result +++ b/tools/deploy/mysql_test/test_suite/join/r/mysql/join_merge.result @@ -1295,13 +1295,13 @@ Outputs & filters: merge_directions([ASC], [ASC]) 2 - output([t7.a], [t7.b], [t7.c], [t7.d], [cast(t7.a, DECIMAL(10, 0))]), filter(nil), rowset=256 sort_keys([cast(t7.a, DECIMAL(10, 0)), ASC], [t7.d, ASC]) - 3 - output([t7.a], [t7.d], [t7.b], [t7.c]), filter(nil), rowset=256 + 3 - output([t7.a], [t7.d], [t7.b], [t7.c], [cast(t7.a, DECIMAL(10, 0))]), filter(nil), rowset=256 access([t7.a], [t7.d], [t7.b], [t7.c]), partitions(p0) is_index_back=false, is_global_index=false, range_key([t7.__pk_increment]), range(MIN ; MAX)always true 4 - output([t2.a], [t2.b], [t2.c], [cast(t2.b, DECIMAL(-1, -1))]), filter(nil), rowset=256 sort_keys([cast(t2.b, DECIMAL(-1, -1)), ASC], [t2.c, ASC]) - 5 - output([t2.b], [t2.c], [t2.a]), filter(nil), rowset=256 + 5 - output([t2.b], [t2.c], [t2.a], [cast(t2.b, DECIMAL(-1, -1))]), filter(nil), rowset=256 access([t2.b], [t2.c], [t2.a]), partitions(p0) is_index_back=false, is_global_index=false, range_key([t2.__pk_increment]), range(MIN ; MAX)always true @@ -1438,13 +1438,13 @@ Outputs & filters: merge_directions([ASC], [ASC]) 2 - output([t7.a], [t7.b], [t7.c], [t7.d], [cast(t7.a, DECIMAL(10, 0))]), filter(nil), rowset=256 sort_keys([cast(t7.a, DECIMAL(10, 0)), ASC], [t7.d, ASC]) - 3 - output([t7.a], [t7.d], [t7.b], [t7.c]), filter(nil), rowset=256 + 3 - output([t7.a], [t7.d], [t7.b], [t7.c], [cast(t7.a, DECIMAL(10, 0))]), filter(nil), rowset=256 access([t7.a], [t7.d], [t7.b], [t7.c]), partitions(p0) is_index_back=false, is_global_index=false, range_key([t7.__pk_increment]), range(MIN ; MAX)always true 4 - output([t2.a], [t2.b], [t2.c], [cast(t2.b, DECIMAL(-1, -1))]), filter(nil), rowset=256 sort_keys([cast(t2.b, DECIMAL(-1, -1)), ASC], [t2.c, ASC]) - 5 - output([t2.b], [t2.c], [t2.a]), filter(nil), rowset=256 + 5 - output([t2.b], [t2.c], [t2.a], [cast(t2.b, DECIMAL(-1, -1))]), filter(nil), rowset=256 access([t2.b], [t2.c], [t2.a]), partitions(p0) is_index_back=false, is_global_index=false, range_key([t2.__pk_increment]), range(MIN ; MAX)always true @@ -1587,13 +1587,13 @@ Outputs & filters: merge_directions([ASC], [ASC]) 2 - output([t7.a], [t7.b], [t7.c], [t7.d], [cast(t7.a, DECIMAL(10, 0))]), filter(nil), rowset=256 sort_keys([cast(t7.a, DECIMAL(10, 0)), ASC], [t7.d, ASC]) - 3 - output([t7.a], [t7.d], [t7.b], [t7.c]), filter(nil), rowset=256 + 3 - output([t7.a], [t7.d], [t7.b], [t7.c], [cast(t7.a, DECIMAL(10, 0))]), filter(nil), rowset=256 access([t7.a], [t7.d], [t7.b], [t7.c]), partitions(p0) is_index_back=false, is_global_index=false, range_key([t7.__pk_increment]), range(MIN ; MAX)always true 4 - output([t2.a], [t2.b], [t2.c], [cast(t2.b, DECIMAL(-1, -1))]), filter(nil), rowset=256 sort_keys([cast(t2.b, DECIMAL(-1, -1)), ASC], [t2.c, ASC]) - 5 - output([t2.b], [t2.c], [t2.a]), filter(nil), rowset=256 + 5 - output([t2.b], [t2.c], [t2.a], [cast(t2.b, DECIMAL(-1, -1))]), filter(nil), rowset=256 access([t2.b], [t2.c], [t2.a]), partitions(p0) is_index_back=false, is_global_index=false, range_key([t2.__pk_increment]), range(MIN ; MAX)always true diff --git a/tools/deploy/mysql_test/test_suite/static_engine/r/mysql/px_basic.result b/tools/deploy/mysql_test/test_suite/static_engine/r/mysql/px_basic.result index 95fe05b234..42d879328d 100644 --- a/tools/deploy/mysql_test/test_suite/static_engine/r/mysql/px_basic.result +++ b/tools/deploy/mysql_test/test_suite/static_engine/r/mysql/px_basic.result @@ -101,8 +101,8 @@ Outputs & filters: dop=2 2 - output([a.c2 + 1 + a.c1], [a.c1], [a.c2]), filter(nil), rowset=256 sort_keys([a.c2 + 1 + a.c1, ASC]) - 3 - output([a.c1], [a.c2]), filter(nil), rowset=256 - 4 - output([a.c1], [a.c2]), filter(nil), rowset=256 + 3 - output([a.c1], [a.c2], [a.c2 + 1 + a.c1]), filter(nil), rowset=256 + 4 - output([a.c1], [a.c2], [a.c2 + 1 + a.c1]), filter(nil), rowset=256 access([a.c1], [a.c2]), partitions(p[0-4]) is_index_back=false, is_global_index=false, range_key([a.c1]), range(MIN ; MAX)always true @@ -249,7 +249,7 @@ Outputs & filters: dop=2 2 - output([a.c1], [a.c2 + 2], [a.c2]), filter(nil), rowset=256 sort_keys([a.c1, ASC], [a.c2 + 2, ASC]) - 3 - output([a.c1], [a.c2]), filter(nil), rowset=256 + 3 - output([a.c1], [a.c2 + 2], [a.c2]), filter(nil), rowset=256 equal_conds([abs(cast(a.c2, BIGINT(-1, 0))) + 2 = b.c1]), other_conds(nil) 4 - output([a.c1], [a.c2], [abs(cast(a.c2, BIGINT(-1, 0))) + 2]), filter(nil), rowset=256 5 - output([a.c1], [a.c2], [abs(cast(a.c2, BIGINT(-1, 0))) + 2]), filter(nil), rowset=256 @@ -357,7 +357,7 @@ Outputs & filters: dop=2 2 - output([a.c1], [b.c1 + 2], [b.c1], [b.c2], [a.c2]), filter(nil), rowset=256 sort_keys([a.c1, ASC], [b.c1 + 2, ASC]) - 3 - output([a.c1], [b.c1], [b.c2], [a.c2]), filter(nil), rowset=256 + 3 - output([a.c1], [b.c1 + 2], [b.c1], [b.c2], [a.c2]), filter(nil), rowset=256 equal_conds([a.c1 + 2 = b.c2 + 1]), other_conds(nil) 4 - output([b.c1], [b.c2]), filter(nil), rowset=256 5 - output([b.c1], [b.c2]), filter(nil), rowset=256