From ed08722e44b2ab29b98069959840c166adbe2831 Mon Sep 17 00:00:00 2001 From: hy-guo Date: Thu, 28 Sep 2023 03:10:01 +0000 Subject: [PATCH] fix select * from subquery ambiguously error --- src/sql/resolver/dml/ob_column_namespace_checker.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/sql/resolver/dml/ob_column_namespace_checker.cpp b/src/sql/resolver/dml/ob_column_namespace_checker.cpp index 170055ccb0..6dabf76425 100644 --- a/src/sql/resolver/dml/ob_column_namespace_checker.cpp +++ b/src/sql/resolver/dml/ob_column_namespace_checker.cpp @@ -278,8 +278,12 @@ int ObColumnNamespaceChecker::check_column_exists(const TableItem &table_item, c for (int64_t i = 0; OB_SUCC(ret) && i < ref_stmt->get_select_item_size(); ++i) { SelectItem& tmp_select_item = ref_stmt->get_select_item(i); if (ObCharset::case_compat_mode_equal(col_name, tmp_select_item.alias_name_)) { - unduplicable_count += (tmp_select_item.expr_->is_column_ref_expr() - && static_cast(tmp_select_item.expr_)->is_joined_dup_column()) ? 0 : 1; + unduplicable_count += ((tmp_select_item.expr_->is_column_ref_expr() + && static_cast(tmp_select_item.expr_)->is_joined_dup_column()) + || !(tmp_select_item.expr_->is_aggr_expr())) ? 0 : 1; + /* Unduplicable_count is use for column duplicated report in oracle mode. + * It seems only aggr funcs in PIVOT shoulds cause this error. + */ if (!is_exist) { // set the is_exist = true, is there is a column with the same column name. // no matter the column is a duplicable column, we should set the exists to true.