From a0ff8aaa32887fddc3ac7d3f25bd1e3d96c77c49 Mon Sep 17 00:00:00 2001 From: jz0 Date: Thu, 19 Aug 2021 17:53:21 +0800 Subject: [PATCH] Patch bug fixes to opensource branch. --- src/sql/optimizer/ob_log_table_scan.cpp | 9 +- .../optimizer/ob_log_temp_table_insert.cpp | 6 +- src/sql/optimizer/ob_optimizer_util.cpp | 2 + src/sql/rewrite/ob_transform_or_expansion.cpp | 44 +- src/sql/rewrite/ob_transform_or_expansion.h | 4 +- .../rewrite/ob_transform_query_push_down.cpp | 2 - src/sql/rewrite/ob_transform_simplify.cpp | 41 +- src/sql/rewrite/ob_transform_simplify.h | 4 +- src/sql/rewrite/ob_transform_utils.cpp | 92 +- src/sql/rewrite/ob_transform_utils.h | 14 + .../test_transformer_plan_after_el.result | 10 +- ...t_transformer_plan_after_trans_aggr.result | 24 +- .../test_transformer_stmt_after_el.result | 138 +++ ...t_transformer_stmt_after_trans_aggr.result | 897 +++++------------- 14 files changed, 523 insertions(+), 764 deletions(-) diff --git a/src/sql/optimizer/ob_log_table_scan.cpp b/src/sql/optimizer/ob_log_table_scan.cpp index 43e15220d9..42112ae0ba 100644 --- a/src/sql/optimizer/ob_log_table_scan.cpp +++ b/src/sql/optimizer/ob_log_table_scan.cpp @@ -685,9 +685,12 @@ int ObLogTableScan::extract_access_exprs( } else if (OB_ISNULL(expr)) { ret = OB_ERR_UNEXPECTED; LOG_WARN("expr is null", K(col_idx), K(ret)); - } else if (OB_FAIL(expr->formalize(opt_ctx->get_session_info()))) { - LOG_WARN("failed to formalize the new expr", K(ret)); - } else { /*do nothing*/ + } else { + expr->set_ref_id(get_table_id(), column_schema->get_column_id()); + if (OB_FAIL(expr->formalize(opt_ctx->get_session_info()))) { + LOG_WARN("failed to formalize the new expr", K(ret)); + } else { /*do nothing*/ + } } if (OB_SUCC(ret)) { if (OB_FAIL(rowkey_exprs.push_back(expr))) { diff --git a/src/sql/optimizer/ob_log_temp_table_insert.cpp b/src/sql/optimizer/ob_log_temp_table_insert.cpp index 02d5de352d..fb252d9eba 100644 --- a/src/sql/optimizer/ob_log_temp_table_insert.cpp +++ b/src/sql/optimizer/ob_log_temp_table_insert.cpp @@ -43,8 +43,10 @@ int ObLogTempTableInsert::allocate_exchange_post(AllocExchContext* ctx) LOG_WARN("get unexpected null", K(child), K(ret)); } else if (child->get_sharding_info().is_distributed()) { sharding_info_.set_location_type(child->get_sharding_info().get_location_type()); - } else { - ret = sharding_info_.copy_with_part_keys(child->get_sharding_info()); + } else if (OB_FAIL(sharding_info_.copy_with_part_keys(child->get_sharding_info()))) { + LOG_WARN("failed to copy sharding info", K(ret)); + } else if (sharding_info_.is_match_all()) { + sharding_info_.set_location_type(OB_TBL_LOCATION_LOCAL); } return ret; } diff --git a/src/sql/optimizer/ob_optimizer_util.cpp b/src/sql/optimizer/ob_optimizer_util.cpp index 690545c470..4c87d2693e 100644 --- a/src/sql/optimizer/ob_optimizer_util.cpp +++ b/src/sql/optimizer/ob_optimizer_util.cpp @@ -666,6 +666,8 @@ int ObOptimizerUtil::compute_const_exprs( LOG_WARN("failed to push back expr", K(ret)); } else { /*do nothing*/ } + } else if (T_BOOL == const_expr->get_expr_type()) { + // is true/false will not be regarded as const } else if (OB_FAIL(add_var_to_array_no_dup(const_exprs, common_expr))) { LOG_WARN("failed to push back expr", K(ret)); } else { /*do nothing*/ diff --git a/src/sql/rewrite/ob_transform_or_expansion.cpp b/src/sql/rewrite/ob_transform_or_expansion.cpp index 4bcbdff45f..445393b81c 100644 --- a/src/sql/rewrite/ob_transform_or_expansion.cpp +++ b/src/sql/rewrite/ob_transform_or_expansion.cpp @@ -647,7 +647,6 @@ int ObTransformOrExpansion::adjust_or_expansion_stmt(const int64_t transformed_e ObRawExprFactory* expr_factory = NULL; ObRawExpr* transformed_expr = NULL; ObSEArray removed_subqueries; - ObSEArray need_add_subqueries; if (OB_ISNULL(ctx_) || OB_ISNULL(session_info = ctx_->session_info_) || OB_ISNULL(expr_factory = ctx_->expr_factory_)) { ret = OB_INVALID_ARGUMENT; @@ -667,31 +666,22 @@ int ObTransformOrExpansion::adjust_or_expansion_stmt(const int64_t transformed_e LOG_WARN("null transformed expr", K(ret)); } else if (OB_FAIL(or_expansion_stmt->get_condition_exprs().remove(transformed_expr_pos))) { LOG_WARN("failed to remove condition expr", K(ret)); - } else if (transformed_expr->has_flag(CNT_SUB_QUERY) && - OB_FAIL(ObTransformUtils::extract_query_ref_expr(transformed_expr, removed_subqueries))) { - LOG_WARN("failed to extract query ref expr", K(ret)); - } else if (OB_FAIL(ObOptimizerUtil::remove_item(or_expansion_stmt->get_subquery_exprs(), removed_subqueries))) { - LOG_WARN("failed to remove subquery exprs", K(ret)); } else if (T_OP_OR == transformed_expr->get_expr_type()) { ObSEArray generated_exprs; if (OB_FAIL(create_expr_for_or_expr( - *transformed_expr, param_pos, can_union_distinct, generated_exprs, need_add_subqueries))) { + *transformed_expr, param_pos, can_union_distinct, generated_exprs))) { LOG_WARN("failed to create expr", K(ret)); } else if (OB_FAIL(append(or_expansion_stmt->get_condition_exprs(), generated_exprs))) { LOG_WARN("failed to append expr", K(ret)); - } else if (OB_FAIL(append(or_expansion_stmt->get_subquery_exprs(), need_add_subqueries))) { - LOG_WARN("failed to append expr", K(ret)); } else { /*do nothing*/ } } else if (T_OP_IN == transformed_expr->get_expr_type()) { ObSEArray generated_exprs; if (OB_FAIL(create_expr_for_in_expr( - *transformed_expr, param_pos, can_union_distinct, generated_exprs, need_add_subqueries))) { + *transformed_expr, param_pos, can_union_distinct, generated_exprs))) { LOG_WARN("failed to create expr", K(ret), K(generated_exprs)); } else if (OB_FAIL(append(or_expansion_stmt->get_condition_exprs(), generated_exprs))) { LOG_WARN("failed to append exprs", K(ret)); - } else if (OB_FAIL(append(or_expansion_stmt->get_subquery_exprs(), need_add_subqueries))) { - LOG_WARN("failed to append expr", K(ret)); } else { /*do nothing*/ } } else { @@ -701,13 +691,31 @@ int ObTransformOrExpansion::adjust_or_expansion_stmt(const int64_t transformed_e if (OB_SUCC(ret)) { if (OB_FAIL(or_expansion_stmt->formalize_stmt(session_info))) { LOG_WARN("failed to formalize stmt", K(ret)); + } else { + // clean unused subqueries + ObSEArray relation_exprs; + ObSEArray used_subquery_exprs; + if (OB_FAIL(or_expansion_stmt->get_relation_exprs(relation_exprs))) { + LOG_WARN("failed to get relation exprs"); + } else if (OB_FAIL(ObTransformUtils::extract_query_ref_expr(relation_exprs, used_subquery_exprs))) { + LOG_WARN("failed to get query exprs"); + } else { + for (int64_t i = 0; OB_SUCC(ret) && i < or_expansion_stmt->get_subquery_exprs().count(); ++i) { + ObQueryRefRawExpr *expr = or_expansion_stmt->get_subquery_exprs().at(i); + if (ObOptimizerUtil::find_item(used_subquery_exprs, expr)) { + // do nothing + } else if (OB_FAIL(ObOptimizerUtil::remove_item(or_expansion_stmt->get_subquery_exprs(), expr))) { + LOG_WARN("failed to remove item from subquery exprs", K(ret)); + } + } + } } } return ret; } int ObTransformOrExpansion::create_expr_for_in_expr(const ObRawExpr& transformed_expr, const int64_t param_pos, - bool can_union_distinct, ObIArray& generated_exprs, ObIArray& subqueries) + bool can_union_distinct, ObIArray& generated_exprs) { int ret = OB_SUCCESS; const ObRawExpr* left_expr = NULL; @@ -735,8 +743,6 @@ int ObTransformOrExpansion::create_expr_for_in_expr(const ObRawExpr& transformed } else if (OB_UNLIKELY(param_pos < 0) || OB_UNLIKELY(param_pos >= right_expr->get_param_count())) { ret = OB_ERR_UNEXPECTED; LOG_WARN("unexpected expr pos", K(param_pos), K(right_expr->get_param_count()), K(ret)); - } else if (OB_FAIL(ObTransformUtils::extract_query_ref_expr(const_cast(left_expr), subqueries))) { - LOG_WARN("failed to extract query ref expr", K(ret)); } for (int64_t i = can_union_distinct ? param_pos : 0; OB_SUCC(ret) && i <= param_pos; ++i) { if (OB_FAIL(ObRawExprUtils::create_equal_expr( @@ -758,7 +764,7 @@ int ObTransformOrExpansion::create_expr_for_in_expr(const ObRawExpr& transformed } int ObTransformOrExpansion::create_expr_for_or_expr(ObRawExpr& transformed_expr, const int64_t param_pos, - bool can_union_distinct, common::ObIArray& generated_exprs, ObIArray& subqueries) + bool can_union_distinct, common::ObIArray& generated_exprs) { int ret = OB_SUCCESS; ObRawExprFactory* expr_factory = NULL; @@ -780,16 +786,12 @@ int ObTransformOrExpansion::create_expr_for_or_expr(ObRawExpr& transformed_expr, LOG_WARN("null expr", K(ret)); } else if (i == param_pos) { temp_expr = expr; - if (OB_FAIL(ObTransformUtils::extract_query_ref_expr(expr, subqueries))) { - LOG_WARN("failed to extract query ref expr", K(ret)); - } else if (OB_FAIL(ObTransformUtils::flatten_expr(temp_expr, generated_exprs))) { + if (OB_FAIL(ObTransformUtils::flatten_expr(temp_expr, generated_exprs))) { LOG_WARN("failed to flatten expr", K(ret)); } else { /*do nothing*/ } } else if (can_union_distinct) { /*do nothing */ - } else if (OB_FAIL(ObTransformUtils::extract_query_ref_expr(expr, subqueries))) { - LOG_WARN("failed to extract query ref expr", K(ret)); } else if (OB_FAIL(ObRawExprUtils::build_lnnvl_expr(*expr_factory, expr, temp_expr))) { LOG_WARN("failed to create lnnvl expr", K(ret)); } else if (OB_FAIL(generated_exprs.push_back(temp_expr))) { diff --git a/src/sql/rewrite/ob_transform_or_expansion.h b/src/sql/rewrite/ob_transform_or_expansion.h index 0e5f47606b..e9163f406d 100644 --- a/src/sql/rewrite/ob_transform_or_expansion.h +++ b/src/sql/rewrite/ob_transform_or_expansion.h @@ -70,9 +70,9 @@ private: int adjust_or_expansion_stmt(const int64_t transformed_expr_pos, const int64_t param_pos, bool can_union_distinct, ObSelectStmt*& or_expansion_stmt); int create_expr_for_in_expr(const ObRawExpr& transformed_expr, const int64_t param_pos, bool can_union_distinct, - common::ObIArray& generated_exprs, common::ObIArray& subqueries); + common::ObIArray& generated_exprs); int create_expr_for_or_expr(ObRawExpr& transformed_expr, const int64_t param_pos, bool can_union_distinct, - common::ObIArray& generated_exprs, common::ObIArray& subqueries); + common::ObIArray& generated_exprs); int preprocess_or_condition(ObSelectStmt* select_stmt, ObRawExpr* expr, bool& can_union_distinct, bool& spj_is_unique, bool& skip_this_cond, const bool is_topk); diff --git a/src/sql/rewrite/ob_transform_query_push_down.cpp b/src/sql/rewrite/ob_transform_query_push_down.cpp index 498039fb84..bab51398ac 100644 --- a/src/sql/rewrite/ob_transform_query_push_down.cpp +++ b/src/sql/rewrite/ob_transform_query_push_down.cpp @@ -577,8 +577,6 @@ int ObTransformQueryPushDown::push_down_stmt_exprs(ObSelectStmt* select_stmt, Ob LOG_WARN("view stmt append subquery failed", K(ret)); } else if (OB_FAIL(adjust_stmt_hints(select_stmt, view_stmt))) { LOG_WARN("failed to adjust hints", K(ret)); - } else if (OB_FAIL(view_stmt->adjust_subquery_list())) { - LOG_WARN("failed to adjust subquery list", K(ret)); } else if (OB_FAIL(view_stmt->adjust_subquery_stmt_parent(select_stmt, view_stmt))) { LOG_WARN("failed to adjust subquery stmt parent", K(ret)); } else { diff --git a/src/sql/rewrite/ob_transform_simplify.cpp b/src/sql/rewrite/ob_transform_simplify.cpp index 171e6a5633..f77e307a7e 100644 --- a/src/sql/rewrite/ob_transform_simplify.cpp +++ b/src/sql/rewrite/ob_transform_simplify.cpp @@ -722,7 +722,8 @@ int ObTransformSimplify::replace_is_null_condition(ObDMLStmt* stmt, bool& trans_ if (OB_ISNULL(cond = stmt->get_condition_expr(i))) { ret = OB_ERR_UNEXPECTED; LOG_WARN("condition expr is null", K(ret)); - } else if (OB_FAIL(inner_replace_is_null_condition(stmt, stmt->get_condition_exprs().at(i), is_happened))) { + } else if (OB_FAIL(inner_replace_is_null_condition(stmt, stmt->get_condition_exprs().at(i), + ObTransformUtils::NULLABLE_SCOPE::NS_WHERE, is_happened))) { LOG_WARN("failed to replace is null expr", K(ret)); } else { trans_happened |= is_happened; @@ -731,7 +732,8 @@ int ObTransformSimplify::replace_is_null_condition(ObDMLStmt* stmt, bool& trans_ if (OB_SUCC(ret) && stmt->is_select_stmt()) { ObSelectStmt* sel_stmt = static_cast(stmt); for (int64_t i = 0; OB_SUCC(ret) && i < sel_stmt->get_having_expr_size(); ++i) { - if (OB_FAIL(inner_replace_is_null_condition(sel_stmt, sel_stmt->get_having_exprs().at(i), is_happened))) { + if (OB_FAIL(inner_replace_is_null_condition(sel_stmt, sel_stmt->get_having_exprs().at(i), + ObTransformUtils::NULLABLE_SCOPE::NS_TOP, is_happened))) { LOG_WARN("failed to replace is null expr", K(ret)); } else { trans_happened |= is_happened; @@ -742,7 +744,7 @@ int ObTransformSimplify::replace_is_null_condition(ObDMLStmt* stmt, bool& trans_ return ret; } -int ObTransformSimplify::inner_replace_is_null_condition(ObDMLStmt* stmt, ObRawExpr*& expr, bool& trans_happened) +int ObTransformSimplify::inner_replace_is_null_condition(ObDMLStmt* stmt, ObRawExpr*& expr, int nullable_scope, bool& trans_happened) { int ret = OB_SUCCESS; bool is_happened = false; @@ -764,7 +766,7 @@ int ObTransformSimplify::inner_replace_is_null_condition(ObDMLStmt* stmt, ObRawE if (OB_ISNULL(temp = op_expr->get_param_expr(i))) { ret = OB_ERR_UNEXPECTED; LOG_WARN("null expr", K(ret)); - } else if (OB_FAIL(SMART_CALL(inner_replace_is_null_condition(stmt, temp, is_happened)))) { + } else if (OB_FAIL(SMART_CALL(inner_replace_is_null_condition(stmt, temp, nullable_scope, is_happened)))) { LOG_WARN("failed to replace is null expr", K(ret)); } else { trans_happened |= is_happened; @@ -775,7 +777,7 @@ int ObTransformSimplify::inner_replace_is_null_condition(ObDMLStmt* stmt, ObRawE if (OB_SUCC(ret) && (T_OP_IS == expr->get_expr_type() || T_OP_IS_NOT == expr->get_expr_type())) { // do transforamtion for its own exprs - if (OB_FAIL(do_replace_is_null_condition(stmt, expr, is_happened))) { + if (OB_FAIL(do_replace_is_null_condition(stmt, expr, nullable_scope, is_happened))) { LOG_WARN("failed to replace is null condition", K(ret)); } else { trans_happened |= is_happened; @@ -794,7 +796,7 @@ int ObTransformSimplify::inner_replace_is_null_condition(ObDMLStmt* stmt, ObRawE return ret; } -int ObTransformSimplify::do_replace_is_null_condition(ObDMLStmt* stmt, ObRawExpr*& expr, bool& trans_happened) +int ObTransformSimplify::do_replace_is_null_condition(ObDMLStmt* stmt, ObRawExpr*& expr, int nullable_scope, bool& trans_happened) { int ret = OB_SUCCESS; trans_happened = false; @@ -820,6 +822,7 @@ int ObTransformSimplify::do_replace_is_null_condition(ObDMLStmt* stmt, ObRawExpr is_expected = true; } else if (child_0->is_column_ref_expr()) { bool sql_auto_is_null = false; + bool found = false; const ObColumnRefRawExpr* col_expr = static_cast(child_0); uint64_t table_id = col_expr->get_table_id(); if (OB_FAIL(ctx_->session_info_->get_sql_auto_is_null(sql_auto_is_null))) { @@ -830,6 +833,11 @@ int ObTransformSimplify::do_replace_is_null_condition(ObDMLStmt* stmt, ObRawExpr !col_expr->get_result_type().is_date() && !(sql_auto_is_null && col_expr->is_auto_increment()))) { if (OB_FAIL(is_expected_table_for_replace(stmt, table_id, is_expected))) { LOG_WARN("fail to judge expected table", K(ret), K(table_id), K(is_expected)); + } else if (is_expected && OB_FAIL(ObTransformUtils::check_nullable_exprs_in_groupby(stmt, + const_cast(col_expr), nullable_scope, found))) { + LOG_WARN("fail to checkin nullable in groupby", K(ret), K(table_id), K(is_expected)); + } else if (found) { + is_expected = false; } } } @@ -1008,19 +1016,18 @@ int ObTransformSimplify::is_expected_table_for_replace(ObDMLStmt* stmt, uint64_t LOG_WARN("fail to judge expected table", K(ret)); } else { /*do nothing*/ } - } else { - // table from current stmt - if (table_item->is_basic_table() || table_item->is_generated_table()) { - bool is_on_null_side = false; - if (OB_FAIL(ObOptimizerUtil::is_table_on_null_side(stmt, table_item->table_id_, is_on_null_side))) { - LOG_WARN("check is table on null side failed", K(ret), K(*table_item)); - } else { - is_expected = !is_on_null_side; - } + } else if (table_item->is_basic_table()) { + bool is_on_null_side = false; + if (OB_FAIL(ObOptimizerUtil::is_table_on_null_side(stmt, table_item->table_id_, is_on_null_side))) { + LOG_WARN("check is table on null side failed", K(ret), K(*table_item)); } else { - ret = OB_ERR_UNEXPECTED; - LOG_WARN("unexpected table item type", K_(table_item->type)); + is_expected = !is_on_null_side; } + } else if (table_item->is_generated_table()) { + is_expected = false; + } else { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected table item type", K_(table_item->type)); } return ret; } diff --git a/src/sql/rewrite/ob_transform_simplify.h b/src/sql/rewrite/ob_transform_simplify.h index 52383b0095..cad9f75f80 100644 --- a/src/sql/rewrite/ob_transform_simplify.h +++ b/src/sql/rewrite/ob_transform_simplify.h @@ -38,8 +38,8 @@ private: int having_filter_can_be_pushed_down( const ObRawExpr* having_filter, const ObSelectStmt& select_stmt, const bool has_rownum, bool& can_be); int replace_is_null_condition(ObDMLStmt* stmt, bool& trans_happened); - int inner_replace_is_null_condition(ObDMLStmt* stmt, ObRawExpr*& expr, bool& trans_happened); - int do_replace_is_null_condition(ObDMLStmt* stmt, ObRawExpr*& expr, bool& trans_happened); + int inner_replace_is_null_condition(ObDMLStmt* stmt, ObRawExpr*& expr, int nullalbe_scope, bool& trans_happened); + int do_replace_is_null_condition(ObDMLStmt* stmt, ObRawExpr*& expr, int nullalbe_scope, bool& trans_happened); int replace_op_null_condition(ObDMLStmt* stmt, bool& trans_happened); int replace_cmp_null_condition( ObRawExpr*& expr, const ObDMLStmt& stmt, const ParamStore& param_store, bool& trans_happened); diff --git a/src/sql/rewrite/ob_transform_utils.cpp b/src/sql/rewrite/ob_transform_utils.cpp index 08227785fe..1b58eaad76 100644 --- a/src/sql/rewrite/ob_transform_utils.cpp +++ b/src/sql/rewrite/ob_transform_utils.cpp @@ -2091,6 +2091,63 @@ int ObTransformUtils::find_expr(const ObIArray& source, const return ret; } +int ObTransformUtils::check_nullable_exprs_in_groupby(ObDMLStmt *stmt, ObRawExpr *expr, int nullable_scope, bool &found) +{ + int ret = OB_SUCCESS; + found = false; + ObSelectStmt *select_stmt = NULL; + if (OB_ISNULL(stmt) || OB_ISNULL(expr)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("invalid input", K(stmt), K(expr)); + } else if (!stmt->is_select_stmt()) { + // do nothing + } else if (FALSE_IT(select_stmt = static_cast(stmt))) { + // do nothing + } else if (NULLABLE_SCOPE::NS_TOP == nullable_scope && + OB_FAIL(find_expr_in_groupby_clause(select_stmt, expr, found))) { + LOG_WARN("failed to find expr in group by clause", K(ret)); + } else if (!found && NULLABLE_SCOPE::NS_TOP == nullable_scope && + OB_FAIL(find_expr_in_scala_groupby(select_stmt, expr, found))) { + LOG_WARN("failed to find expr in scala group by", K(ret)); + } else { + // todo: other nullable scenarios + } + return ret; +} + +int ObTransformUtils::find_expr_in_groupby_clause(ObSelectStmt *select_stmt, ObRawExpr *column_expr, bool &found) +{ + int ret = OB_SUCCESS; + found = false; + if (OB_ISNULL(select_stmt) || OB_ISNULL(column_expr)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("invalid input", K(select_stmt), K(column_expr)); + // case: select c1 + c2 from t group by rollup (c1+c2); + // can't deduce c1 + c2 as not null even if c1 and c2 are not null + //const ObIArray &rollup_exprs = select_stmt->get_rollup_exprs(); + } else if (ObOptimizerUtil::find_item(select_stmt->get_rollup_exprs(), column_expr)) { + found = true; + } + return ret; +} + +int ObTransformUtils::find_expr_in_scala_groupby(ObSelectStmt *select_stmt, ObRawExpr *expr, bool &found) +{ + int ret = OB_SUCCESS; + found = false; + if (OB_ISNULL(select_stmt) || OB_ISNULL(expr)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("invalid input", K(select_stmt), K(expr)); + } else if (select_stmt->is_scala_group_by() && + (expr->is_column_ref_expr() || + (expr->is_aggr_expr() && T_FUN_COUNT != expr->get_expr_type()))) { + // case: select * from t1 where (c1, c2) not in (select pk, max(pk) from t2); + // can't deduce pk and max(pk) as not null when t2 is empty + found = true; + } + return ret; +} + /** * column <=> ? or ? <=> column * column is ? or column != ? @@ -7045,29 +7102,28 @@ int ObTransformUtils::extract_column_contained_expr( } else if (is_stack_overflow) { ret = OB_SIZE_OVERFLOW; LOG_WARN("too deep recursive", K(ret)); - } else if (!expr->get_expr_levels().has_member(stmt_level)) { + } else if (!(expr->get_expr_levels().has_member(stmt_level) || expr->has_flag(CNT_SUB_QUERY))) { /*do nothing */ - } else if (!expr->is_query_ref_expr() && !expr->get_relation_ids().is_empty()) { - if (!expr->is_column_ref_expr() && !expr->is_aggr_expr() && !expr->is_win_func_expr() && - expr->get_expr_levels().num_members() == 1 && !ObRawExprUtils::find_expr(contain_column_exprs, expr) && - OB_FAIL(contain_column_exprs.push_back(expr))) { - LOG_WARN("failed to push back expr", K(ret)); - } else { - for (int64_t i = 0; OB_SUCC(ret) && i < expr->get_param_count(); ++i) { - if (OB_FAIL( - SMART_CALL(extract_column_contained_expr(expr->get_param_expr(i), stmt_level, contain_column_exprs)))) { - LOG_WARN("failed to extract column contained expr", K(ret)); - } else { /*do nothing*/ - } - } - } - } else if (expr->is_query_ref_expr()) { - if (OB_FAIL(extract_stmt_column_contained_expr( + } else if (expr->is_query_ref_expr() && expr->get_expr_level() == stmt_level) { + if (OB_FAIL(contain_column_exprs.push_back(expr))) { + LOG_WARN("failed to push back expr into column array", K(ret)); + } else if (OB_FAIL(extract_stmt_column_contained_expr( static_cast(expr)->get_ref_stmt(), stmt_level, contain_column_exprs))) { LOG_WARN("failed to extract stmt column contained expr", K(ret)); } else { /*do nothing*/ } - } else { /*do nothing*/ + } else if (!expr->get_relation_ids().is_empty() && !expr->is_column_ref_expr() && !expr->is_aggr_expr() && !expr->is_win_func_expr() && + expr->get_expr_levels().num_members() == 1 && !ObRawExprUtils::find_expr(contain_column_exprs, expr) && + OB_FAIL(contain_column_exprs.push_back(expr))) { + LOG_WARN("failed to push back expr", K(ret)); + } else { + for (int64_t i = 0; OB_SUCC(ret) && i < expr->get_param_count(); ++i) { + if (OB_FAIL( + SMART_CALL(extract_column_contained_expr(expr->get_param_expr(i), stmt_level, contain_column_exprs)))) { + LOG_WARN("failed to extract column contained expr", K(ret)); + } else { /*do nothing*/ + } + } } return ret; } diff --git a/src/sql/rewrite/ob_transform_utils.h b/src/sql/rewrite/ob_transform_utils.h index 5bc4b2ef4d..71e6022dff 100644 --- a/src/sql/rewrite/ob_transform_utils.h +++ b/src/sql/rewrite/ob_transform_utils.h @@ -81,6 +81,14 @@ private: }; public: + enum NULLABLE_SCOPE { + NS_FROM = 1 << 0, + NS_WHERE = 1 << 1, + NS_GROUPBY = 1 << 2, + NS_HAVING = 1 << 3, + NS_TOP = 1 << 4 + }; + static int is_correlated_expr(const ObRawExpr* expr, int32_t correlated_level, bool& is_correlated); static int is_correlated_subquery(ObSelectStmt* subquery, @@ -268,6 +276,12 @@ public: static int find_expr(const ObIArray& source, const ObRawExpr* target, bool& bret); + static int check_nullable_exprs_in_groupby(ObDMLStmt *stmt, ObRawExpr *expr, int nullable_scope, bool &found); + + static int find_expr_in_groupby_clause(ObSelectStmt *select_stmt, ObRawExpr *column_expr, bool &found); + + static int find_expr_in_scala_groupby(ObSelectStmt *select_stmt, ObRawExpr *expr, bool &found); + /** * @brief is_null_propagate_type * white list for null propagate expr diff --git a/unittest/sql/rewrite/result/test_transformer_plan_after_el.result b/unittest/sql/rewrite/result/test_transformer_plan_after_el.result index 53330854b5..cf332cfdfd 100644 --- a/unittest/sql/rewrite/result/test_transformer_plan_after_el.result +++ b/unittest/sql/rewrite/result/test_transformer_plan_after_el.result @@ -165,9 +165,9 @@ SQL: select * from t2 left join (select * from t1) as v on t2.c1 = v.c2 where ( ========================================= |ID|OPERATOR |NAME|EST. ROWS|COST| ----------------------------------------- -|0 |NESTED-LOOP JOIN| |0 |121 | -|1 | SUBPLAN SCAN |v |0 |121 | -|2 | TABLE SCAN |t1 |100 |90 | +|0 |NESTED-LOOP JOIN| |0 |140 | +|1 | SUBPLAN SCAN |v |0 |140 | +|2 | TABLE SCAN |t1 |0 |140 | |3 | TABLE GET |t2 |1 |36 | ========================================= @@ -175,9 +175,9 @@ Outputs & filters: ------------------------------------- 0 - output([t2.c1], [t2.c2], [t2.c3], [v.c1], [v.c2]), filter(nil), conds(nil), nl_params_([v.c2]) - 1 - output([v.c2], [v.c1]), filter([(T_OP_IS, v.c2, NULL, 0)], [? > (T_OP_IS_NOT, v.c2, NULL, 0)]), + 1 - output([v.c2], [v.c1]), filter(nil), access([v.c2], [v.c1]) - 2 - output([t1.c1], [t1.c2]), filter(nil), + 2 - output([t1.c1], [t1.c2]), filter([(T_OP_IS, t1.c2, NULL, 0)], [? > (T_OP_IS_NOT, t1.c2, NULL, 0)], [(T_OP_IS_NOT, t1.c1, NULL, 0)]), access([t1.c1], [t1.c2]), partitions(p0) 3 - output([t2.c1], [t2.c2], [t2.c3]), filter(nil), access([t2.c1], [t2.c2], [t2.c3]), partitions(p0) diff --git a/unittest/sql/rewrite/result/test_transformer_plan_after_trans_aggr.result b/unittest/sql/rewrite/result/test_transformer_plan_after_trans_aggr.result index 01e39f0fb6..f21b832eda 100644 --- a/unittest/sql/rewrite/result/test_transformer_plan_after_trans_aggr.result +++ b/unittest/sql/rewrite/result/test_transformer_plan_after_trans_aggr.result @@ -2025,23 +2025,19 @@ Outputs & filters: *************** Case 84 *************** SQL: select max(c3) from t9 where c2 is TRUE; -====================================================== -|ID|OPERATOR |NAME |EST. ROWS|COST| ------------------------------------------------------- -|0 |SCALAR GROUP BY| |1 |37 | -|1 | SUBPLAN SCAN |VIEW1 |1 |37 | -|2 | TABLE SCAN |t9(idx_t9,Reverse)|1 |37 | -====================================================== +============================================== +|ID|OPERATOR |NAME |EST. ROWS|COST| +---------------------------------------------- +|0 |SCALAR GROUP BY| |1 |97 | +|1 | TABLE SCAN |t9(idx_t9)|99 |78 | +============================================== Outputs & filters: ------------------------------------- - 0 - output([T_FUN_MAX(VIEW1.c3)]), filter(nil), - group(nil), agg_func([T_FUN_MAX(VIEW1.c3)]) - 1 - output([VIEW1.c3]), filter(nil), - access([VIEW1.c3]) - 2 - output([t9.c3]), filter([(T_OP_IS, t9.c2, 1, 0)], [(T_OP_IS_NOT, t9.c3, NULL, 0)]), - access([t9.c2], [t9.c3]), partitions(p0), - limit(1), offset(nil) + 0 - output([T_FUN_MAX(t9.c3)]), filter(nil), + group(nil), agg_func([T_FUN_MAX(t9.c3)]) + 1 - output([t9.c3]), filter([(T_OP_IS, t9.c2, 1, 0)]), + access([t9.c2], [t9.c3]), partitions(p0) *************** Case 85 *************** SQL: select max(c3) from t9 where c2 = 1 and c1 = 1; diff --git a/unittest/sql/rewrite/result/test_transformer_stmt_after_el.result b/unittest/sql/rewrite/result/test_transformer_stmt_after_el.result index 770104df26..f8e4ca83f5 100644 --- a/unittest/sql/rewrite/result/test_transformer_stmt_after_el.result +++ b/unittest/sql/rewrite/result/test_transformer_stmt_after_el.result @@ -12095,6 +12095,144 @@ SQL: select * from t2 left join (select * from t1) as v on t2.c1 = v.c2 where ( ] } ] + }, + { + "item_type":"T_OP_IS_NOT", + "result_type": { + "meta": { + "type":"INT", + "collation":"binary", + "coercibility":"NUMERIC" + }, + "accuracy": { + "length":-1, + "precision":1, + "scale":0 + }, + "flag":1, + "calc_type": { + "type":"DECIMAL", + "collation":"binary", + "coercibility":"NUMERIC" + } + }, + "expr_info": [ + "CNT_CONST", + "CNT_COLUMN" + ], + "rel_id": [ + 2 + ], + "expr_levels": [ + 0 + ], + "children": [ + { + "item_type":"T_REF_COLUMN", + "result_type": { + "meta": { + "type":"INT", + "collation":"binary", + "coercibility":"NUMERIC" + }, + "accuracy": { + "length":-1, + "precision":11, + "scale":0 + }, + "flag":16387, + "calc_type": { + "type":"NULL", + "collation":"invalid_type", + "coercibility":"INVALID" + } + }, + "expr_info": [ + "IS_COLUMN", + "CNT_COLUMN" + ], + "rel_id": [ + 2 + ], + "table_id":-3, + "column_id":16, + "database_name":"", + "table_name":"v", + "synonym_name":"", + "synonym_db_name":"", + "column_name":"c1", + "expr_level":0, + "expr_levels": [ + 0 + ], + "column_flags":0, + "enum_set_values": [ + ], + "is_lob_column":false, + "is_unpivot_mocked_column":false, + "is_hidden":false + }, + { + "item_type":"T_NULL", + "result_type": { + "meta": { + "type":"NULL", + "collation":"binary", + "coercibility":"IGNORABLE" + }, + "accuracy": { + "length":0, + "precision":-1, + "scale":-1 + }, + "flag":0, + "calc_type": { + "type":"NULL", + "collation":"invalid_type", + "coercibility":"INVALID" + } + }, + "expr_info": [ + "IS_CONST", + "CNT_CONST" + ], + "rel_id": [ + ], + "value": { + "NULL":"NULL" + } + }, + { + "item_type":"T_BOOL", + "result_type": { + "meta": { + "type":"TINYINT", + "collation":"binary", + "coercibility":"NUMERIC" + }, + "accuracy": { + "length":-1, + "precision":-1, + "scale":-1 + }, + "flag":1, + "calc_type": { + "type":"NULL", + "collation":"invalid_type", + "coercibility":"INVALID" + } + }, + "expr_info": [ + "IS_CONST", + "CNT_CONST" + ], + "rel_id": [ + ], + "value": { + "TINYINT":0 + } + } + ] }, { "item_type":"T_OP_EQ", diff --git a/unittest/sql/rewrite/result/test_transformer_stmt_after_trans_aggr.result b/unittest/sql/rewrite/result/test_transformer_stmt_after_trans_aggr.result index ba714135e0..f8db9fb27b 100644 --- a/unittest/sql/rewrite/result/test_transformer_stmt_after_trans_aggr.result +++ b/unittest/sql/rewrite/result/test_transformer_stmt_after_trans_aggr.result @@ -75787,14 +75787,14 @@ SQL: select max(c3) from t9 where c2 is TRUE; "transpose_item":null, "table": [ { - "table_id":-2, - "table_name":"VIEW1", - "alias_name":"VIEW1", + "table_id":1099511677787, + "table_name":"t9", + "alias_name":"", "synonym_name":"", "synonym_db_name":"", - "table_type":2, - "ref_id":-1, - "database_name":"", + "table_type":0, + "ref_id":1099511677787, + "database_name":"opt", "for_update":false, "wait":-1, "mock_id":-1, @@ -75809,15 +75809,71 @@ SQL: select max(c3) from t9 where c2 is TRUE; ], "column": [ { - "column_id":16, - "table_id":-2, + "column_id":17, + "table_id":1099511677787, + "column":"c2", + "auto_filled_timestamp":false, + "default_value": { + "NULL":"NULL" + }, + "base_tid":1099511677787, + "base_cid":17, + "expression": { + "item_type":"T_REF_COLUMN", + "result_type": { + "meta": { + "type":"INT", + "collation":"binary", + "coercibility":"NUMERIC" + }, + "accuracy": { + "length":-1, + "precision":11, + "scale":0 + }, + "flag":0, + "calc_type": { + "type":"NULL", + "collation":"invalid_type", + "coercibility":"INVALID" + } + }, + "expr_info": [ + "IS_COLUMN", + "CNT_COLUMN" + ], + "rel_id": [ + 1 + ], + "table_id":1099511677787, + "column_id":17, + "database_name":"opt", + "table_name":"t9", + "synonym_name":"", + "synonym_db_name":"", + "column_name":"c2", + "expr_level":0, + "expr_levels": [ + 0 + ], + "column_flags":0, + "enum_set_values": [ + ], + "is_lob_column":false, + "is_unpivot_mocked_column":false, + "is_hidden":false + } + }, + { + "column_id":18, + "table_id":1099511677787, "column":"c3", "auto_filled_timestamp":false, "default_value": { "NULL":"NULL" }, - "base_tid":-1, - "base_cid":-1, + "base_tid":1099511677787, + "base_cid":18, "expression": { "item_type":"T_REF_COLUMN", "result_type": { @@ -75845,10 +75901,10 @@ SQL: select max(c3) from t9 where c2 is TRUE; "rel_id": [ 1 ], - "table_id":-2, - "column_id":16, - "database_name":"", - "table_name":"VIEW1", + "table_id":1099511677787, + "column_id":18, + "database_name":"opt", + "table_name":"t9", "synonym_name":"", "synonym_db_name":"", "column_name":"c3", @@ -75927,10 +75983,10 @@ SQL: select max(c3) from t9 where c2 is TRUE; "rel_id": [ 1 ], - "table_id":-2, - "column_id":16, - "database_name":"", - "table_name":"VIEW1", + "table_id":1099511677787, + "column_id":18, + "database_name":"opt", + "table_name":"t9", "synonym_name":"", "synonym_db_name":"", "column_name":"c3", @@ -75982,7 +76038,7 @@ SQL: select max(c3) from t9 where c2 is TRUE; "nocycle":false, "from": [ { - "table_id":-2, + "table_id":1099511677787, "is_join":false } ], @@ -75991,6 +76047,146 @@ SQL: select max(c3) from t9 where c2 is TRUE; "connect_by": [ ], "where": [ + { + "item_type":"T_OP_IS", + "result_type": { + "meta": { + "type":"INT", + "collation":"binary", + "coercibility":"NUMERIC" + }, + "accuracy": { + "length":-1, + "precision":1, + "scale":0 + }, + "flag":1, + "calc_type": { + "type":"DECIMAL", + "collation":"binary", + "coercibility":"NUMERIC" + } + }, + "expr_info": [ + "IS_IS_EXPR", + "CNT_CONST", + "CNT_COLUMN", + "CNT_IS_EXPR" + ], + "rel_id": [ + 1 + ], + "expr_levels": [ + 0 + ], + "children": [ + { + "item_type":"T_REF_COLUMN", + "result_type": { + "meta": { + "type":"INT", + "collation":"binary", + "coercibility":"NUMERIC" + }, + "accuracy": { + "length":-1, + "precision":11, + "scale":0 + }, + "flag":0, + "calc_type": { + "type":"NULL", + "collation":"invalid_type", + "coercibility":"INVALID" + } + }, + "expr_info": [ + "IS_COLUMN", + "CNT_COLUMN" + ], + "rel_id": [ + 1 + ], + "table_id":1099511677787, + "column_id":17, + "database_name":"opt", + "table_name":"t9", + "synonym_name":"", + "synonym_db_name":"", + "column_name":"c2", + "expr_level":0, + "expr_levels": [ + 0 + ], + "column_flags":0, + "enum_set_values": [ + ], + "is_lob_column":false, + "is_unpivot_mocked_column":false, + "is_hidden":false + }, + { + "item_type":"T_BOOL", + "result_type": { + "meta": { + "type":"TINYINT", + "collation":"binary", + "coercibility":"NUMERIC" + }, + "accuracy": { + "length":1, + "precision":1, + "scale":0 + }, + "flag":1, + "calc_type": { + "type":"NULL", + "collation":"invalid_type", + "coercibility":"INVALID" + } + }, + "expr_info": [ + "IS_CONST", + "CNT_CONST" + ], + "rel_id": [ + ], + "value": { + "TINYINT":1 + } + }, + { + "item_type":"T_BOOL", + "result_type": { + "meta": { + "type":"TINYINT", + "collation":"binary", + "coercibility":"NUMERIC" + }, + "accuracy": { + "length":-1, + "precision":-1, + "scale":-1 + }, + "flag":1, + "calc_type": { + "type":"NULL", + "collation":"invalid_type", + "coercibility":"INVALID" + } + }, + "expr_info": [ + "IS_CONST", + "CNT_CONST" + ], + "rel_id": [ + ], + "value": { + "TINYINT":0 + } + } + ] + } ], "group_by": [ ], @@ -76059,10 +76255,10 @@ SQL: select max(c3) from t9 where c2 is TRUE; "rel_id": [ 1 ], - "table_id":-2, - "column_id":16, - "database_name":"", - "table_name":"VIEW1", + "table_id":1099511677787, + "column_id":18, + "database_name":"opt", + "table_name":"t9", "synonym_name":"", "synonym_db_name":"", "column_name":"c3", @@ -76162,661 +76358,6 @@ SQL: select max(c3) from t9 where c2 is TRUE; "pseudo_column_like_exprs": [ ], "child_stmts": [ - { - "stmt_type":1, - "transpose_item":null, - "table": [ - { - "table_id":1099511677787, - "table_name":"t9", - "alias_name":"", - "synonym_name":"", - "synonym_db_name":"", - "table_type":0, - "ref_id":1099511677787, - "database_name":"opt", - "for_update":false, - "wait":-1, - "mock_id":-1, - "view_base_item":-1 - } - ], - "joined_table": [ - ], - "semi_info": [ - ], - "partition_express": [ - ], - "column": [ - { - "column_id":17, - "table_id":1099511677787, - "column":"c2", - "auto_filled_timestamp":false, - "default_value": { - "NULL":"NULL" - }, - "base_tid":1099511677787, - "base_cid":17, - "expression": { - "item_type":"T_REF_COLUMN", - "result_type": { - "meta": { - "type":"INT", - "collation":"binary", - "coercibility":"NUMERIC" - }, - "accuracy": { - "length":-1, - "precision":11, - "scale":0 - }, - "flag":0, - "calc_type": { - "type":"NULL", - "collation":"invalid_type", - "coercibility":"INVALID" - } - }, - "expr_info": [ - "IS_COLUMN", - "CNT_COLUMN" - ], - "rel_id": [ - 1 - ], - "table_id":1099511677787, - "column_id":17, - "database_name":"opt", - "table_name":"t9", - "synonym_name":"", - "synonym_db_name":"", - "column_name":"c2", - "expr_level":0, - "expr_levels": [ - 0 - ], - "column_flags":0, - "enum_set_values": [ - ], - "is_lob_column":false, - "is_unpivot_mocked_column":false, - "is_hidden":false - } - }, - { - "column_id":18, - "table_id":1099511677787, - "column":"c3", - "auto_filled_timestamp":false, - "default_value": { - "NULL":"NULL" - }, - "base_tid":1099511677787, - "base_cid":18, - "expression": { - "item_type":"T_REF_COLUMN", - "result_type": { - "meta": { - "type":"INT", - "collation":"binary", - "coercibility":"NUMERIC" - }, - "accuracy": { - "length":-1, - "precision":11, - "scale":0 - }, - "flag":0, - "calc_type": { - "type":"NULL", - "collation":"invalid_type", - "coercibility":"INVALID" - } - }, - "expr_info": [ - "IS_COLUMN", - "CNT_COLUMN" - ], - "rel_id": [ - 1 - ], - "table_id":1099511677787, - "column_id":18, - "database_name":"opt", - "table_name":"t9", - "synonym_name":"", - "synonym_db_name":"", - "column_name":"c3", - "expr_level":0, - "expr_levels": [ - 0 - ], - "column_flags":0, - "enum_set_values": [ - ], - "is_lob_column":false, - "is_unpivot_mocked_column":false, - "is_hidden":false - } - } - ], - "select": [ - { - "expression": { - "item_type":"T_REF_COLUMN", - "result_type": { - "meta": { - "type":"INT", - "collation":"binary", - "coercibility":"NUMERIC" - }, - "accuracy": { - "length":-1, - "precision":11, - "scale":0 - }, - "flag":0, - "calc_type": { - "type":"NULL", - "collation":"invalid_type", - "coercibility":"INVALID" - } - }, - "expr_info": [ - "IS_COLUMN", - "CNT_COLUMN" - ], - "rel_id": [ - 1 - ], - "table_id":1099511677787, - "column_id":18, - "database_name":"opt", - "table_name":"t9", - "synonym_name":"", - "synonym_db_name":"", - "column_name":"c3", - "expr_level":0, - "expr_levels": [ - 0 - ], - "column_flags":0, - "enum_set_values": [ - ], - "is_lob_column":false, - "is_unpivot_mocked_column":false, - "is_hidden":false - }, - "is_alias":false, - "alias_name":"c3", - "expr_name":"max(c3)", - "default": { - "NULL":"NULL" - }, - "paramed_alias_name":"", - "questions_pos": [ - ], - "params_idx": [ - ], - "esc_str_flag":false, - "need_check_dup_name":false, - "implicit_filled":false, - "is_unpivot_mocked_column":false, - "is_hidden_rowid":false - } - ], - "distinct":false, - "rollup":false, - "nocycle":false, - "from": [ - { - "table_id":1099511677787, - "is_join":false - } - ], - "start_with": [ - ], - "connect_by": [ - ], - "where": [ - { - "item_type":"T_OP_IS", - "result_type": { - "meta": { - "type":"INT", - "collation":"binary", - "coercibility":"NUMERIC" - }, - "accuracy": { - "length":-1, - "precision":1, - "scale":0 - }, - "flag":1, - "calc_type": { - "type":"DECIMAL", - "collation":"binary", - "coercibility":"NUMERIC" - } - }, - "expr_info": [ - "IS_IS_EXPR", - "CNT_CONST", - "CNT_COLUMN", - "CNT_IS_EXPR" - ], - "rel_id": [ - 1 - ], - "expr_levels": [ - 0 - ], - "children": [ - { - "item_type":"T_REF_COLUMN", - "result_type": { - "meta": { - "type":"INT", - "collation":"binary", - "coercibility":"NUMERIC" - }, - "accuracy": { - "length":-1, - "precision":11, - "scale":0 - }, - "flag":0, - "calc_type": { - "type":"NULL", - "collation":"invalid_type", - "coercibility":"INVALID" - } - }, - "expr_info": [ - "IS_COLUMN", - "CNT_COLUMN" - ], - "rel_id": [ - 1 - ], - "table_id":1099511677787, - "column_id":17, - "database_name":"opt", - "table_name":"t9", - "synonym_name":"", - "synonym_db_name":"", - "column_name":"c2", - "expr_level":0, - "expr_levels": [ - 0 - ], - "column_flags":0, - "enum_set_values": [ - ], - "is_lob_column":false, - "is_unpivot_mocked_column":false, - "is_hidden":false - }, - { - "item_type":"T_BOOL", - "result_type": { - "meta": { - "type":"TINYINT", - "collation":"binary", - "coercibility":"NUMERIC" - }, - "accuracy": { - "length":1, - "precision":1, - "scale":0 - }, - "flag":1, - "calc_type": { - "type":"NULL", - "collation":"invalid_type", - "coercibility":"INVALID" - } - }, - "expr_info": [ - "IS_CONST", - "CNT_CONST" - ], - "rel_id": [ - ], - "value": { - "TINYINT":1 - } - }, - { - "item_type":"T_BOOL", - "result_type": { - "meta": { - "type":"TINYINT", - "collation":"binary", - "coercibility":"NUMERIC" - }, - "accuracy": { - "length":-1, - "precision":-1, - "scale":-1 - }, - "flag":1, - "calc_type": { - "type":"NULL", - "collation":"invalid_type", - "coercibility":"INVALID" - } - }, - "expr_info": [ - "IS_CONST", - "CNT_CONST" - ], - "rel_id": [ - ], - "value": { - "TINYINT":0 - } - } - ] - }, - { - "item_type":"T_OP_IS_NOT", - "result_type": { - "meta": { - "type":"INT", - "collation":"binary", - "coercibility":"NUMERIC" - }, - "accuracy": { - "length":-1, - "precision":1, - "scale":0 - }, - "flag":1, - "calc_type": { - "type":"DECIMAL", - "collation":"binary", - "coercibility":"NUMERIC" - } - }, - "expr_info": [ - "CNT_CONST", - "CNT_COLUMN" - ], - "rel_id": [ - 1 - ], - "expr_levels": [ - 0 - ], - "children": [ - { - "item_type":"T_REF_COLUMN", - "result_type": { - "meta": { - "type":"INT", - "collation":"binary", - "coercibility":"NUMERIC" - }, - "accuracy": { - "length":-1, - "precision":11, - "scale":0 - }, - "flag":0, - "calc_type": { - "type":"NULL", - "collation":"invalid_type", - "coercibility":"INVALID" - } - }, - "expr_info": [ - "IS_COLUMN", - "CNT_COLUMN" - ], - "rel_id": [ - 1 - ], - "table_id":1099511677787, - "column_id":18, - "database_name":"opt", - "table_name":"t9", - "synonym_name":"", - "synonym_db_name":"", - "column_name":"c3", - "expr_level":0, - "expr_levels": [ - 0 - ], - "column_flags":0, - "enum_set_values": [ - ], - "is_lob_column":false, - "is_unpivot_mocked_column":false, - "is_hidden":false - }, - { - "item_type":"T_NULL", - "result_type": { - "meta": { - "type":"NULL", - "collation":"binary", - "coercibility":"IGNORABLE" - }, - "accuracy": { - "length":-1, - "precision":-1, - "scale":-1 - }, - "flag":0, - "calc_type": { - "type":"NULL", - "collation":"invalid_type", - "coercibility":"INVALID" - } - }, - "expr_info": [ - "IS_CONST", - "CNT_CONST" - ], - "rel_id": [ - ], - "value": { - "NULL":"NULL" - } - }, - { - "item_type":"T_BOOL", - "result_type": { - "meta": { - "type":"TINYINT", - "collation":"binary", - "coercibility":"NUMERIC" - }, - "accuracy": { - "length":-1, - "precision":-1, - "scale":-1 - }, - "flag":1, - "calc_type": { - "type":"NULL", - "collation":"invalid_type", - "coercibility":"INVALID" - } - }, - "expr_info": [ - "IS_CONST", - "CNT_CONST" - ], - "rel_id": [ - ], - "value": { - "TINYINT":0 - } - } - ] - } - ], - "group_by": [ - ], - "rollup": [ - ], - "having": [ - ], - "aggr_func": [ - ], - "order_by": [ - { - "expression": { - "item_type":"T_REF_COLUMN", - "result_type": { - "meta": { - "type":"INT", - "collation":"binary", - "coercibility":"NUMERIC" - }, - "accuracy": { - "length":-1, - "precision":11, - "scale":0 - }, - "flag":0, - "calc_type": { - "type":"NULL", - "collation":"invalid_type", - "coercibility":"INVALID" - } - }, - "expr_info": [ - "IS_COLUMN", - "CNT_COLUMN" - ], - "rel_id": [ - 1 - ], - "table_id":1099511677787, - "column_id":18, - "database_name":"opt", - "table_name":"t9", - "synonym_name":"", - "synonym_db_name":"", - "column_name":"c3", - "expr_level":0, - "expr_levels": [ - 0 - ], - "column_flags":0, - "enum_set_values": [ - ], - "is_lob_column":false, - "is_unpivot_mocked_column":false, - "is_hidden":false - }, - "ascending":"NULLs_last_desc" - } - ], - "limit": { - "item_type":"T_INT", - "result_type": { - "meta": { - "type":"BIGINT", - "collation":"binary", - "coercibility":"NUMERIC" - }, - "accuracy": { - "length":1, - "precision":1, - "scale":0 - }, - "flag":1, - "calc_type": { - "type":"NULL", - "collation":"invalid_type", - "coercibility":"INVALID" - } - }, - "expr_info": [ - "IS_CONST", - "CNT_CONST" - ], - "rel_id": [ - ], - "value": { - "BIGINT":1 - } - }, - "win_func": [ - ], - "offset":null, - "show_stmt_ctx": { - "is_from_show_stmt":false, - "global_scope":false, - "tenant_id":-1, - "show_database_id":-1, - "show_table_id":-1, - "grants_user_id":-1, - "show_seed":false - }, - "hint": { - "read_static":false, - "no_rewrite":false, - "frozen_version":-1, - "topk_precision":-1, - "sharding_minimum_row_count":0, - "query_timeout":-1, - "hotspot":false, - "index": [ - ], - "read_consistency":-1, - "join_ordered":false, - "join_order": [ - ], - "merge_hint_ids": [ - ], - "hash_hint_ids": [ - ], - "no_hash_hint_ids": [ - ], - "nl_hint_ids": [ - ], - "part_hints": [ - ], - "use_late_materialization":-1, - "log_level":"", - "max_concurrent":-1, - "only_concurrent_hint":false, - "has_hint_exclude_concurrent":false, - "parallel":-1, - "use_px":2, - "use_expand":0, - "use_view_merge":0, - "use_unnest":0, - "use_place_groupby":0, - "use join filter": [ - ], - "org_pq_distributes": [ - ], - "pq_distributes": [ - ], - "pdml_option":-1 - }, - "user_variables": [ - ], - "query_context": { - "param_num":0, - "fetch_cur_time":true, - "calculable_items": [ - ] - }, - "current_level":0, - "pseudo_column_like_exprs": [ - ], - "child_stmts": [ - ], - "is_hierarchical_query":false - } ], "is_hierarchical_query":false } -- GitLab