fix shared exprs bug for sort operator
This commit is contained in:
@ -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<ExprProdu
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLogicalOperator::force_pushdown_exprs(ObAllocExprContext &ctx)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (ObLogOpType::LOG_SORT != get_type()) {
|
||||
// do nothing
|
||||
} else {
|
||||
ObSEArray<ObRawExpr*, 4> exprs;
|
||||
uint64_t producer_id = OB_INVALID_ID;
|
||||
if (OB_FAIL(static_cast<ObLogSort*>(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;
|
||||
|
||||
@ -1195,6 +1195,8 @@ public:
|
||||
|
||||
int extract_non_const_exprs(const ObIArray<ObRawExpr*> &input_exprs,
|
||||
ObIArray<ObRawExpr*> &non_const_exprs);
|
||||
int force_pushdown_exprs(ObAllocExprContext &ctx);
|
||||
int get_pushdown_producer_id(uint64_t &producer_id);
|
||||
|
||||
int extract_shared_exprs(const ObIArray<ObRawExpr*> &exprs,
|
||||
ObAllocExprContext &ctx,
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
Reference in New Issue
Block a user