From 9164739462e50b95883333c46910d6c402e68596 Mon Sep 17 00:00:00 2001 From: yinyj17 Date: Fri, 15 Mar 2024 10:20:30 +0000 Subject: [PATCH] fix count to exists bug with order or limit --- src/sql/rewrite/ob_transform_count_to_exists.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/sql/rewrite/ob_transform_count_to_exists.cpp b/src/sql/rewrite/ob_transform_count_to_exists.cpp index 0d7fb705d..ca3b2be7f 100644 --- a/src/sql/rewrite/ob_transform_count_to_exists.cpp +++ b/src/sql/rewrite/ob_transform_count_to_exists.cpp @@ -202,7 +202,9 @@ int ObTransformCountToExists::check_trans_valid(ObDMLStmt *stmt, ObRawExpr *expr } else if (has_rownum) { // do nothing } else if (tmp_subquery_expr->get_ref_count() > 1 || - tmp_subquery->has_having() || !tmp_subquery->is_scala_group_by()) { + tmp_subquery->has_having() || !tmp_subquery->is_scala_group_by() || + tmp_subquery->has_order_by() || tmp_subquery->has_limit() || + tmp_subquery->has_window_function_filter()) { // only scalar group by subquery without having and referred by once can be transformed OPT_TRACE("only scalar group by subquery without having and referred by once can be transformed"); } else if (OB_FAIL(check_sel_expr_valid(sel_expr,