oracle json construct function refaction && oracle json expr option clause syntax support

This commit is contained in:
obdev
2023-08-02 06:54:16 +00:00
committed by ob-robot
parent 755b53ef5e
commit 90def6ad4a
16 changed files with 478 additions and 367 deletions

View File

@ -1938,9 +1938,27 @@ int ObRawExprPrinter::print_json_query(ObSysFunRawExpr *expr)
if (OB_SUCC(ret)) {
if (!static_cast<ObConstRawExpr*>(expr->get_param_expr(3))->get_value().is_int()) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("scalar value isn't int value");
LOG_WARN("truncate value isn't int value");
} else {
int64_t type = static_cast<ObConstRawExpr*>(expr->get_param_expr(3))->get_value().get_int();
switch (type) {
case 1:
DATA_PRINTF(" TRUNCATE");
break;
case 0:
break;
default:
break;
}
}
}
if (OB_SUCC(ret)) {
if (!static_cast<ObConstRawExpr*>(expr->get_param_expr(4))->get_value().is_int()) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("scalar value isn't int value");
} else {
int64_t type = static_cast<ObConstRawExpr*>(expr->get_param_expr(4))->get_value().get_int();
switch (type) {
case 0:
DATA_PRINTF(" ALLOW SCALARS");
@ -1958,11 +1976,11 @@ int ObRawExprPrinter::print_json_query(ObSysFunRawExpr *expr)
}
}
if (OB_SUCC(ret)) {
if (!static_cast<ObConstRawExpr*>(expr->get_param_expr(4))->get_value().is_int()) {
if (!static_cast<ObConstRawExpr*>(expr->get_param_expr(5))->get_value().is_int()) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("pretty value isn't int value");
} else {
int64_t type = static_cast<ObConstRawExpr*>(expr->get_param_expr(4))->get_value().get_int();
int64_t type = static_cast<ObConstRawExpr*>(expr->get_param_expr(5))->get_value().get_int();
switch (type) {
case 0:
DATA_PRINTF("");
@ -1978,11 +1996,11 @@ int ObRawExprPrinter::print_json_query(ObSysFunRawExpr *expr)
}
}
if (OB_SUCC(ret)) {
if (!static_cast<ObConstRawExpr*>(expr->get_param_expr(5))->get_value().is_int()) {
if (!static_cast<ObConstRawExpr*>(expr->get_param_expr(6))->get_value().is_int()) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("ascii value isn't int value");
} else {
int64_t type = static_cast<ObConstRawExpr*>(expr->get_param_expr(5))->get_value().get_int();
int64_t type = static_cast<ObConstRawExpr*>(expr->get_param_expr(6))->get_value().get_int();
switch (type) {
case 0:
DATA_PRINTF("");
@ -1998,11 +2016,11 @@ int ObRawExprPrinter::print_json_query(ObSysFunRawExpr *expr)
}
}
if (OB_SUCC(ret)) {
if (!static_cast<ObConstRawExpr*>(expr->get_param_expr(6))->get_value().is_int()) {
if (!static_cast<ObConstRawExpr*>(expr->get_param_expr(7))->get_value().is_int()) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("wrapper value isn't int value");
} else {
int64_t type = static_cast<ObConstRawExpr*>(expr->get_param_expr(6))->get_value().get_int();
int64_t type = static_cast<ObConstRawExpr*>(expr->get_param_expr(7))->get_value().get_int();
switch (type) {
case 0:
DATA_PRINTF(" WITHOUT WRAPPER");
@ -2038,11 +2056,11 @@ int ObRawExprPrinter::print_json_query(ObSysFunRawExpr *expr)
}
}
if (OB_SUCC(ret)) {
if (!static_cast<ObConstRawExpr*>(expr->get_param_expr(7))->get_value().is_int()) {
if (!static_cast<ObConstRawExpr*>(expr->get_param_expr(8))->get_value().is_int()) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("type value isn't int value");
} else {
int64_t type = static_cast<ObConstRawExpr*>(expr->get_param_expr(7))->get_value().get_int();
int64_t type = static_cast<ObConstRawExpr*>(expr->get_param_expr(8))->get_value().get_int();
switch (type) {
case 0:
DATA_PRINTF(" error on error");
@ -2069,11 +2087,11 @@ int ObRawExprPrinter::print_json_query(ObSysFunRawExpr *expr)
}
}
if (OB_SUCC(ret)) {
if (!static_cast<ObConstRawExpr*>(expr->get_param_expr(8))->get_value().is_int()) {
if (!static_cast<ObConstRawExpr*>(expr->get_param_expr(9))->get_value().is_int()) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("type value isn't int value");
} else {
int64_t type = static_cast<ObConstRawExpr*>(expr->get_param_expr(8))->get_value().get_int();
int64_t type = static_cast<ObConstRawExpr*>(expr->get_param_expr(9))->get_value().get_int();
switch (type) {
case 0:
DATA_PRINTF(" error on empty");
@ -2099,29 +2117,28 @@ int ObRawExprPrinter::print_json_query(ObSysFunRawExpr *expr)
}
}
}
if (lib::is_oracle_mode()) {
if (OB_SUCC(ret)) {
if (!static_cast<ObConstRawExpr*>(expr->get_param_expr(9))->get_value().is_int()) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("type value isn't int value");
} else {
int64_t type = static_cast<ObConstRawExpr*>(expr->get_param_expr(9))->get_value().get_int();
switch (type) {
case 0:
DATA_PRINTF(" error on mismatch");
break;
case 1:
case 2:
DATA_PRINTF(" null on mismatch");
break;
case 3:
DATA_PRINTF(" dot on mismatch");
break;
default:
ret = OB_ERR_UNEXPECTED;
LOG_WARN("invalid type value.", K(type));
break;
}
if (OB_SUCC(ret)) {
if (!static_cast<ObConstRawExpr*>(expr->get_param_expr(10))->get_value().is_int()) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("type value isn't int value");
} else {
int64_t type = static_cast<ObConstRawExpr*>(expr->get_param_expr(10))->get_value().get_int();
switch (type) {
case 0:
DATA_PRINTF(" error on mismatch");
break;
case 1:
case 2:
DATA_PRINTF(" null on mismatch");
break;
case 3:
DATA_PRINTF(" dot on mismatch");
break;
default:
ret = OB_ERR_UNEXPECTED;
LOG_WARN("invalid type value.", K(type));
break;
}
}
}
@ -2337,7 +2354,7 @@ int ObRawExprPrinter::print_json_expr(ObSysFunRawExpr *expr)
}
case T_FUN_SYS_JSON_QUERY: {
// json query (json doc, json path, (returning cast_type) opt_scalars opt_pretty opt_ascii opt_wrapper on_error on_empty on_mismatch).
if (OB_UNLIKELY(expr->get_param_count() != 10)) {
if (OB_UNLIKELY(expr->get_param_count() != 11)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("unexpected param count of expr to type", K(ret), KPC(expr), K(expr->get_param_count()));
} else {

View File

@ -5357,7 +5357,7 @@ int ObRawExprResolverImpl::process_json_query_node(const ParseNode *node, ObRawE
if(OB_SUCC(ret) && T_FUN_SYS_JSON_QUERY != node->type_) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("node->type_ error");
} else if (OB_SUCC(ret) && 10 != node->num_child_) {
} else if (OB_SUCC(ret) && 11 != node->num_child_) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("num_child_ error");
}
@ -5402,7 +5402,7 @@ int ObRawExprResolverImpl::process_json_query_node(const ParseNode *node, ObRawE
LOG_WARN("invalid user.table.column, table.column, or column specification", K(ret));
}
// [json_text][json_path][returning_type][scalars][pretty][ascii][wrapper][error_type][empty_type][mismatch]
// [json_text][json_path][returning_type][truncate][scalars][pretty][ascii][wrapper][error_type][empty_type][mismatch]
for (int32_t i = 0; OB_SUCC(ret) && i < num; i++) {
ObRawExpr *para_expr = NULL;
CK(OB_NOT_NULL(node->children_[i]));