fix: do not merge view for rollup stmt

This commit is contained in:
PatZhuang 2024-10-24 06:13:26 +00:00 committed by ob-robot
parent 7277a2e287
commit 8fdf52e4cb
2 changed files with 5 additions and 11 deletions

View File

@ -581,6 +581,9 @@ int ObTransformQueryPushDown::check_select_item_push_down(ObSelectStmt *select_s
if (OB_ISNULL(select_stmt) || OB_ISNULL(view_stmt)) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("stmt is NULL", K(select_stmt), K(view_stmt), K(ret));
} else if (select_stmt->has_rollup()) {
can_be = false;
OPT_TRACE("outer stmt has rollup, can not merge");
} else if (OB_FAIL(check_select_item_subquery(*select_stmt, *view_stmt, check_status))) {
LOG_WARN("failed to check select item has subquery", K(ret));
} else if (!check_status) {
@ -619,17 +622,6 @@ int ObTransformQueryPushDown::check_select_item_push_down(ObSelectStmt *select_s
} else {
can_be = true;
}
if (OB_SUCC(ret) && select_stmt->has_rollup()) {
for (int64_t i = 0; OB_SUCC(ret) && can_be && i < select_exprs.count(); ++i) {
if (OB_ISNULL(select_exprs.at(i))) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("select expr is null", K(ret));
} else {
can_be = !select_exprs.at(i)->is_const_expr() &&
!select_exprs.at(i)->has_flag(CNT_SUB_QUERY);
}
}
}
return ret;
}

View File

@ -192,6 +192,8 @@ int ObTransformViewMerge::transform_in_from_item(ObDMLStmt *stmt,
if (OB_ISNULL(stmt)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("get unexpected null", K(stmt), K(ret));
} else if (stmt->is_select_stmt() && static_cast<ObSelectStmt*>(stmt)->has_rollup()) {
OPT_TRACE("stmt contain rollup, can not merge from item");
} else {
int64_t i = 0;
while (OB_SUCC(ret) && i < stmt->get_from_item_size()) {