提交 92bcaa18 编写于 作者: O obdev 提交者: OB-robot

[bugfix] group by pullup does not handle lob properly

上级 23609b1a
......@@ -872,6 +872,7 @@ int ObTransformAggrSubquery::deduce_query_values(ObDMLStmt &stmt,
// replace_columns_and_aggrs() may change expr result type, e.g.: sum() from ObNumberType
// to ObNullType. This may cause operand implicit cast be added twice, so we erase it first.
ObRawExpr *default_expr = NULL;
ObRawExpr *case_when_expr = NULL;
if (OB_FAIL(real_values.push_back(view_columns.at(i)))) {
LOG_WARN("failed to push back view columns", K(ret));
} else if (is_null_prop.at(i) || !is_outer_join) {
......@@ -890,9 +891,18 @@ int ObTransformAggrSubquery::deduce_query_values(ObDMLStmt &stmt,
not_null_expr,
view_columns.at(i),
default_expr,
real_values.at(i),
case_when_expr,
ctx_))) {
LOG_WARN("failed to build case when expr", K(ret));
} else if (OB_ISNULL(case_when_expr)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("case when expr is null", K(ret));
} else if (OB_FAIL(ObRawExprUtils::try_add_cast_expr_above(ctx_->expr_factory_,
ctx_->session_info_,
*case_when_expr,
view_columns.at(i)->get_result_type(),
real_values.at(i)))) {
LOG_WARN("failed to add cast expr", K(ret));
}
}
}
......
......@@ -923,8 +923,15 @@ int ObTransformGroupByPullup::wrap_case_when(ObSelectStmt &child_stmt,
case_when_expr,
ctx_))) {
LOG_WARN("failed to build case when expr", K(ret));
} else {
expr = case_when_expr;
} else if (OB_ISNULL(case_when_expr)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("case when expr is null", K(ret));
} else if (OB_FAIL(ObRawExprUtils::try_add_cast_expr_above(ctx_->expr_factory_,
ctx_->session_info_,
*case_when_expr,
expr->get_result_type(),
expr))) {
LOG_WARN("failed to add cast expr", K(ret));
}
}
return ret;
......
......@@ -158,23 +158,6 @@ int ObTransformGroupByPushdown::adjust_transform_types(uint64_t &transform_types
return ret;
}
int ObTransformGroupByPushdown::check_join_condition_contain_lob(ObDMLStmt &stmt, bool &is_valid)
{
int ret = OB_SUCCESS;
bool has_lob = false;;
ObSEArray<ObRawExpr *, 4> conditions;
if (OB_FAIL(append(conditions, stmt.get_condition_exprs()))) {
LOG_WARN("extract colum failed", K(ret));
} else if (OB_FAIL(ObTransformUtils::get_on_conditions(stmt, conditions))) {
LOG_WARN("failed to get all on conditions", K(ret));
} else if (OB_FAIL(ObTransformUtils::check_exprs_contain_lob_type(conditions, has_lob))) {
LOG_WARN("check lob failed", K(ret));
} else {
is_valid = !has_lob;
}
return ret;
}
int ObTransformGroupByPushdown::check_groupby_push_down_validity(ObSelectStmt *stmt,
bool &is_valid)
{
......@@ -222,8 +205,6 @@ int ObTransformGroupByPushdown::check_groupby_push_down_validity(ObSelectStmt *s
LOG_WARN("failed to check collation validity", K(ret));
} else if (!is_valid) {
// do nothing
} else if (OB_FAIL(check_join_condition_contain_lob(*stmt, is_valid))) {
LOG_WARN("check join condition contain clob failed", K(ret));
}
for (int64_t i = 0; OB_SUCC(ret) && is_valid && i < stmt->get_aggr_item_size(); ++i) {
ObAggFunRawExpr *aggr_expr = NULL;
......
......@@ -200,7 +200,6 @@ private:
bool disassemble_join = true);
int check_hint_valid(ObDMLStmt &stmt, ObIArray<PushDownParam> &params, bool &is_valid);
int check_join_condition_contain_lob(ObDMLStmt &stmt, bool &is_valid);
private:
// help functions
int64_t get_count_sum_num(const ObIArray<ObRawExpr *> &exprs)
......
......@@ -1232,8 +1232,15 @@ int ObTransformViewMerge::wrap_case_when(ObSelectStmt &child_stmt,
case_when_expr,
ctx_))) {
LOG_WARN("failed to build case when expr", K(ret));
} else {
expr = case_when_expr;
} else if (OB_ISNULL(case_when_expr)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("case expr is null", K(ret), K(case_when_expr));
} else if (OB_FAIL(ObRawExprUtils::try_add_cast_expr_above(ctx_->expr_factory_,
ctx_->session_info_,
*case_when_expr,
expr->get_result_type(),
expr))) {
LOG_WARN("failed to add cast expr above", K(ret));
}
}
return ret;
......
......@@ -1488,8 +1488,15 @@ int ObWhereSubQueryPullup::wrap_case_when(ObSelectStmt &child_stmt,
case_when_expr,
ctx_))) {
LOG_WARN("failed to build case when expr", K(ret));
} else {
expr = case_when_expr;
} else if (OB_ISNULL(case_when_expr)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("case when expr is null", K(ret));
} else if (OB_FAIL(ObRawExprUtils::try_add_cast_expr_above(ctx_->expr_factory_,
ctx_->session_info_,
*case_when_expr,
expr->get_result_type(),
expr))) {
LOG_WARN("failed to add cast expr above", K(ret));
}
}
return ret;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册