diff --git a/src/sql/engine/basic/ob_json_table_op.cpp b/src/sql/engine/basic/ob_json_table_op.cpp index 2c7ed421b4..af794491ab 100644 --- a/src/sql/engine/basic/ob_json_table_op.cpp +++ b/src/sql/engine/basic/ob_json_table_op.cpp @@ -1334,6 +1334,7 @@ int JtColNode::check_col_res_type(JtScanCtx* ctx) } else { if (ob_is_json_tc(obj_type)) { ret = OB_ERR_USAGE_KEYWORD; + LOG_WARN("invalid usage of keyword EXISTS", K(ret)); } else { ret = OB_ERR_NON_NUMERIC_CHARACTER_VALUE; SET_COVER_ERROR(ctx, ret); diff --git a/src/sql/ob_dml_stmt_printer.cpp b/src/sql/ob_dml_stmt_printer.cpp index 6b38be1f00..12890b9c03 100644 --- a/src/sql/ob_dml_stmt_printer.cpp +++ b/src/sql/ob_dml_stmt_printer.cpp @@ -699,7 +699,10 @@ int ObDMLStmtPrinter::print_json_table_nested_column(const TableItem *table_item } else if (col_info.col_type_ == static_cast(COL_TYPE_QUERY)) { // to print returning type OZ (print_json_return_type(col_info.res_type_, col_info.data_type_)); - DATA_PRINTF(" format json"); + ObObjType cast_type = col_info.data_type_.get_obj_type(); + if (cast_type != ObJsonType){ + DATA_PRINTF(" format json"); + } if (OB_FAIL(ret)) { } else if (col_info.allow_scalar_ == 0) { DATA_PRINTF(" allow scalars"); diff --git a/src/sql/ob_sql_define.h b/src/sql/ob_sql_define.h index 3dae7658c5..6a6e62d36a 100644 --- a/src/sql/ob_sql_define.h +++ b/src/sql/ob_sql_define.h @@ -114,7 +114,8 @@ enum JtColType { COL_TYPE_EXISTS, // 2 COL_TYPE_QUERY, // 3 COL_TYPE_VALUE, // 4 - NESTED_COL_TYPE = 5, + NESTED_COL_TYPE, // 5 + COL_TYPE_QUERY_JSON_COL = 6, }; enum ObNameTypeClass diff --git a/src/sql/resolver/dml/ob_dml_resolver.cpp b/src/sql/resolver/dml/ob_dml_resolver.cpp index 0169276d7b..6deabd88e8 100755 --- a/src/sql/resolver/dml/ob_dml_resolver.cpp +++ b/src/sql/resolver/dml/ob_dml_resolver.cpp @@ -7796,9 +7796,13 @@ int ObDMLResolver::resolve_json_table_column_type(const ParseNode &parse_tree, if (col_type == COL_TYPE_ORDINALITY) { data_type.set_int(); data_type.set_accuracy(ObAccuracy::DDL_DEFAULT_ACCURACY[ObInt32Type]); + } else if (col_type == COL_TYPE_QUERY && obj_type == ObJsonType) { + ret = OB_ERR_INVALID_DATA_TYPE_RETURNING; + LOG_WARN("failed to resolve column, not support return json in query column define", K(ret)); } else if (col_type == COL_TYPE_EXISTS || col_type == COL_TYPE_VALUE - || col_type == COL_TYPE_QUERY) { + || col_type == COL_TYPE_QUERY + || col_type == COL_TYPE_QUERY_JSON_COL) { if (ObNumberType == obj_type && parse_tree.int16_values_[2] == -1 && parse_tree.int16_values_[3] == 0) { obj_type = ObIntType; @@ -7957,7 +7961,7 @@ int ObDMLResolver::resolve_json_table_regular_column(const ParseNode &parse_tree LOG_WARN("internal error find jt column failed", K(ret)); } else if ((col_type == COL_TYPE_EXISTS && parse_tree.num_child_ != 4) || (col_type == COL_TYPE_VALUE && parse_tree.num_child_ != 5) || - (col_type == COL_TYPE_QUERY && parse_tree.num_child_ != 6) || + ((col_type == COL_TYPE_QUERY || col_type == COL_TYPE_QUERY_JSON_COL) && parse_tree.num_child_ != 6) || (col_type == COL_TYPE_ORDINALITY && parse_tree.num_child_ != 2)) { ret = OB_ERR_UNEXPECTED; LOG_WARN("fail to resolve json table regular column", K(ret), K(parse_tree.num_child_), K(col_type)); @@ -8012,7 +8016,7 @@ int ObDMLResolver::resolve_json_table_regular_column(const ParseNode &parse_tree } } } - } else if (col_type == COL_TYPE_QUERY) { + } else if (col_type == COL_TYPE_QUERY || col_type == COL_TYPE_QUERY_JSON_COL) { const ParseNode* scalar_node = parse_tree.children_[2]; const ParseNode* wrapper_node = parse_tree.children_[3]; const ParseNode* path_node = parse_tree.children_[4]; @@ -8320,7 +8324,8 @@ int ObDMLResolver::resolve_json_table_column_item(const ParseNode &parse_tree, if (col_type == COL_TYPE_VALUE || col_type == COL_TYPE_QUERY || col_type == COL_TYPE_EXISTS || - col_type == COL_TYPE_ORDINALITY) { + col_type == COL_TYPE_ORDINALITY || + col_type == COL_TYPE_QUERY_JSON_COL) { if (OB_FAIL(resolve_json_table_regular_column(*cur_node, table_item, cur_col_def, cur_node_id, id, cur_column_id))) { LOG_WARN("resolve column defination in json table failed.", K(ret), K(cur_node->value_)); } else if (OB_ISNULL(cur_col_def)) {