diff --git a/src/share/ob_fts_index_builder_util.cpp b/src/share/ob_fts_index_builder_util.cpp index a13e47650302b5ca79c2da6cc24298fa46921344..00cc3626f980c492db79fcce2d96c848c5f75340 100644 --- a/src/share/ob_fts_index_builder_util.cpp +++ b/src/share/ob_fts_index_builder_util.cpp @@ -2161,6 +2161,7 @@ int ObMulValueIndexBuilderUtil::generate_multivalue_column( } else if (old_gen_col != NULL) { //got it gen_col = old_gen_col; + gen_budy_col = data_schema.get_column_schema(gen_col->get_column_id()); } else { //need to add new generated column ObObj default_value; @@ -2387,6 +2388,7 @@ int ObMulValueIndexBuilderUtil::set_multivalue_index_table_columns( "database_id", data_schema.get_database_id(), "table_name", data_schema.get_table_name(), "column name", mvi_col_item.column_name_, K(ret)); + } else if (mvi_column->is_rowkey_column()) { } else if (!mvi_column->is_multivalue_generated_array_column()) { if (OB_FAIL(ObIndexBuilderUtil::add_column(mvi_column, true/*is_index_column*/, diff --git a/src/sql/das/ob_domain_index_lookup_op.cpp b/src/sql/das/ob_domain_index_lookup_op.cpp index df5757a5ca7986ed0f29fc376595e00e695123ff..020b24152430220e2d4cbcd085025c05f0a9e6a4 100644 --- a/src/sql/das/ob_domain_index_lookup_op.cpp +++ b/src/sql/das/ob_domain_index_lookup_op.cpp @@ -831,6 +831,8 @@ int ObMulValueIndexLookupOp::save_rowkeys() if (OB_FAIL(sorter_.do_sort(true))) { LOG_WARN("do rowkey sort failed", K(ret)); + } else { + lookup_rowkey_cnt_ = 0; } for (int64_t i = 0; OB_SUCC(ret) && i < default_row_batch_cnt; ++i) { @@ -859,6 +861,7 @@ int ObMulValueIndexLookupOp::save_rowkeys() LOG_WARN("store lookup key range failed", K(ret), K(scan_param_)); } last_rowkey_ = *idx_row; + ++lookup_rowkey_cnt_; LOG_DEBUG("build data table range", K(ret), K(*idx_row), K(lookup_range), K(scan_param_.key_ranges_.count())); } } diff --git a/src/sql/engine/expr/ob_expr_json_query.cpp b/src/sql/engine/expr/ob_expr_json_query.cpp index cbb3b38fa517c615a920144fc79835dede4b69d3..9d85c1b1c4582d1e49b5cb9a09feb7b628c0b49a 100644 --- a/src/sql/engine/expr/ob_expr_json_query.cpp +++ b/src/sql/engine/expr/ob_expr_json_query.cpp @@ -261,6 +261,14 @@ int ObExprJsonQuery::eval_json_query(const ObExpr &expr, ObEvalCtx &ctx, ObDatum } else if (is_null_result) { // ToDo: need check is_multivalue? res.set_null(); + if (is_multivalue && + OB_FAIL(set_multivalue_result(ctx, temp_allocator, nullptr, expr, + param_ctx->json_param_.error_type_, + in_coll_type, dst_coll_type, + param_ctx->json_param_.error_val_, + param_ctx->json_param_.accuracy_, cast_param, res))) { + LOG_WARN("multi value result set fail", K(ret)); + } } else if (param_ctx->json_param_.on_mismatch_[0] == JSN_QUERY_MISMATCH_DOT && hits.size() == 1 && param_ctx->json_param_.dst_type_ != ObJsonType) { // dot notation @@ -274,7 +282,6 @@ int ObExprJsonQuery::eval_json_query(const ObExpr &expr, ObEvalCtx &ctx, ObDatum } else if (OB_FAIL(ObJsonUtil::set_lob_datum(&temp_allocator, expr, ctx, param_ctx->json_param_.dst_type_, 0, res))) { LOG_WARN("fail to set lob datum from string val", K(ret)); } - // ToDo: need set_multivalue_result? } else if (use_wrapper == 1) { size_t hit_size = hits.size(); ObJsonArray j_arr_res(&temp_allocator); @@ -477,6 +484,7 @@ int ObExprJsonQuery::set_multivalue_result(ObEvalCtx& ctx, ObObj tmp_obj; int64_t pos = str_buff.length(); tmp_obj.set_collation_type(dst_collation); + tmp_obj.set_type(dest_type); if (ob_is_numeric_type(dest_type) || ob_is_temporal_type(dest_type)) { tmp_obj.set_collation_level(CS_LEVEL_NUMERIC); } else { @@ -523,6 +531,7 @@ int ObExprJsonQuery::set_multivalue_result(ObEvalCtx& ctx, ObObj tmp_obj; int64_t pos = str_buff.length(); tmp_obj.set_collation_type(dst_collation); + tmp_obj.set_type(dest_type); if (ob_is_numeric_type(dest_type) || ob_is_temporal_type(dest_type)) { tmp_obj.set_collation_level(CS_LEVEL_NUMERIC); } else { diff --git a/src/sql/engine/expr/ob_expr_json_utils.cpp b/src/sql/engine/expr/ob_expr_json_utils.cpp index dc9d3bc19c37f512c2d04b9025345a0f76d0558d..62fc303c9ae0c2acb7cb5baa87e6dfd9478d9d33 100644 --- a/src/sql/engine/expr/ob_expr_json_utils.cpp +++ b/src/sql/engine/expr/ob_expr_json_utils.cpp @@ -1512,9 +1512,13 @@ int ObJsonUtil::cast_json_scalar_to_sql_obj(common::ObIAllocator *allocator, uint8_t is_type_mismatch = false; if (OB_FAIL(cast_to_res(allocator, ctx, j_base, accuracy, cast_param, res_datum, is_type_mismatch))) { LOG_WARN("fail to cast.", K(ret)); + } else { + res_obj.set_type(obj_type); + res_obj.set_collation_type(collation); + + res_datum.to_obj(res_obj, res_obj.meta_); + res_obj.set_collation_type(collation); } - res_datum.to_obj(res_obj, res_obj.meta_); - res_obj.set_collation_type(collation); } return ret; } diff --git a/src/sql/rewrite/ob_query_range.cpp b/src/sql/rewrite/ob_query_range.cpp index 910deb8258330db371ab38361c32d94788172002..098dd9edbff1cf718c637d5eb64b905ac884cab7 100644 --- a/src/sql/rewrite/ob_query_range.cpp +++ b/src/sql/rewrite/ob_query_range.cpp @@ -3992,6 +3992,37 @@ int ObQueryRange::init_domain_key_part(const ObRawExpr *expr, ObKeyPart *&out_k return ret; } + +int ObQueryRange::set_normal_key_true_or_false(ObKeyPart *&out_key_part, bool is_always_true) +{ + int ret = OB_SUCCESS; + bool is_create_key_part = out_key_part == nullptr; + if (is_create_key_part && OB_FAIL(alloc_full_key_part(out_key_part))) { + LOG_WARN("create full key part failed", K(ret)); + } else if (!is_create_key_part && OB_FAIL(out_key_part->create_normal_key())) { + LOG_WARN("create normal key failed", K(ret)); + } else { + out_key_part->normal_keypart_->include_start_ = false; + out_key_part->normal_keypart_->include_end_ = false; + + out_key_part->normal_keypart_->always_true_ = is_always_true; + out_key_part->normal_keypart_->always_false_ = !is_always_true; + + if (is_always_true) { + out_key_part->normal_keypart_->start_.set_min_value(); + out_key_part->normal_keypart_->end_.set_max_value(); + } else { + out_key_part->normal_keypart_->start_.set_max_value(); + out_key_part->normal_keypart_->end_.set_min_value(); + } + + out_key_part->id_ = table_graph_.key_part_head_->id_; + out_key_part->pos_ = table_graph_.key_part_head_->pos_; + } + return ret; +} + + int ObQueryRange::get_member_of_keyparts(const common::ObObj &const_param, ObKeyPart *&out_key_part, const ObDataTypeCastParams &dtc_params) { int ret = OB_SUCCESS; @@ -4004,10 +4035,11 @@ int ObQueryRange::get_member_of_keyparts(const common::ObObj &const_param, ObKey if (OB_FAIL(ObKeyPart::try_cast_value(dtc_params, allocator_, out_key_part->pos_, cast_obj, cmp))) { LOG_WARN("failed to try cast value type", K(ret)); } else if (cmp != 0) { - if (OB_NOT_NULL(query_range_ctx_)) { + if (OB_FAIL(set_normal_key_true_or_false(out_key_part, true))) { + LOG_WARN("failed set normal key", K(ret)); + } else if (OB_NOT_NULL(query_range_ctx_)) { query_range_ctx_->cur_expr_is_precise_ = false; } - GET_ALWAYS_TRUE_OR_FALSE(true, out_key_part); } else if (OB_FAIL(get_domain_equal_keypart(cast_obj, cast_obj, *out_key_part))) { LOG_WARN("get normal cmp keypart failed", K(ret)); } diff --git a/src/sql/rewrite/ob_query_range.h b/src/sql/rewrite/ob_query_range.h index 9ce8911a0a2cfdb71492e7813d84f4f43739dfd4..0c3b36de3b1b16d5f0bd3ac68fa758727aef45df 100644 --- a/src/sql/rewrite/ob_query_range.h +++ b/src/sql/rewrite/ob_query_range.h @@ -885,6 +885,7 @@ private: int connect_and_or_domain_keyparts(ObIArray &key_parts, ObKeyPart *&out_key_part, ObExecContext *exec_ctx, const ObDataTypeCastParams &dtc_params, bool is_and_op); + int set_normal_key_true_or_false(ObKeyPart *&out_key_part, bool is_always_true); int get_member_of_keyparts(const common::ObObj &const_param, ObKeyPart *&out_key_part, const ObDataTypeCastParams &dtc_params); int get_contain_or_overlaps_keyparts(const common::ObObj &const_param, const common::ObDomainOpType op_type, ObIArray &key_parts, ObKeyPart *&out_key_part,