Fix check expr unique bug

This commit is contained in:
xianyu-w
2023-08-02 12:48:08 +00:00
committed by ob-robot
parent f43e203c8c
commit 9c2f59ba00

View File

@ -4039,7 +4039,12 @@ int ObTransformUtils::check_stmt_unique(const ObSelectStmt *stmt,
} else if (OB_FAIL(stmt->get_select_exprs(select_exprs))) {
LOG_WARN("failed to get select exprs", K(ret));
} else if (stmt->is_set_stmt()) {
if (stmt->is_set_distinct() && ObOptimizerUtil::subset_exprs(select_exprs, exprs)) {
ObSEArray<ObRawExpr *, 16> set_op_exprs;
// [cast(UNION([1]), DATE(-1, -1))]
// cast above set_op_exprs is calulated after the distinct
if (OB_FAIL(ObRawExprUtils::extract_set_op_exprs(select_exprs, set_op_exprs))) {
LOG_WARN("failed to extract set op exprs", K(ret));
} else if (stmt->is_set_distinct() && ObOptimizerUtil::subset_exprs(set_op_exprs, exprs)) {
is_unique = true;
} else if (ObSelectStmt::INTERSECT != stmt->get_set_op()
&& ObSelectStmt::EXCEPT != stmt->get_set_op()) {