diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/BuiltinScalarFunctions.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/BuiltinScalarFunctions.java index a9acc43a595c536..d6c491e9536ac02 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/BuiltinScalarFunctions.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/BuiltinScalarFunctions.java @@ -193,6 +193,7 @@ import org.apache.doris.nereids.trees.expressions.functions.scalar.JsonbParseNullableErrorToNull; import org.apache.doris.nereids.trees.expressions.functions.scalar.JsonbParseNullableErrorToValue; import org.apache.doris.nereids.trees.expressions.functions.scalar.JsonbType; +import org.apache.doris.nereids.trees.expressions.functions.scalar.JsonbValid; import org.apache.doris.nereids.trees.expressions.functions.scalar.LastDay; import org.apache.doris.nereids.trees.expressions.functions.scalar.Least; import org.apache.doris.nereids.trees.expressions.functions.scalar.Left; @@ -565,6 +566,8 @@ public class BuiltinScalarFunctions implements FunctionHelper { scalar(JsonbParseNullableErrorToNull.class, "jsonb_parse_nullable_error_to_null"), scalar(JsonbParseNullableErrorToValue.class, "json_parse_nullable_error_to_value"), scalar(JsonbParseNullableErrorToValue.class, "jsonb_parse_nullable_error_to_value"), + scalar(JsonbValid.class, "json_valid"), + scalar(JsonbValid.class, "jsonb_valid"), scalar(JsonbType.class, "json_type"), scalar(JsonbType.class, "jsonb_type"), scalar(LastDay.class, "last_day"), diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/check/CheckCast.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/check/CheckCast.java index 3026d2ff1441b1c..fe25bb8e7b9f944 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/check/CheckCast.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/check/CheckCast.java @@ -24,6 +24,7 @@ import org.apache.doris.nereids.trees.expressions.Expression; import org.apache.doris.nereids.types.ArrayType; import org.apache.doris.nereids.types.DataType; +import org.apache.doris.nereids.types.JsonType; import org.apache.doris.nereids.types.MapType; import org.apache.doris.nereids.types.StructField; import org.apache.doris.nereids.types.StructType; diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbExtract.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbExtract.java index bbf16255f349369..2cc705b6ccfa17d 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbExtract.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbExtract.java @@ -26,6 +26,7 @@ import org.apache.doris.nereids.types.JsonType; import org.apache.doris.nereids.types.StringType; import org.apache.doris.nereids.types.VarcharType; +import org.apache.doris.nereids.util.ExpressionUtils; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; @@ -39,15 +40,15 @@ public class JsonbExtract extends ScalarFunction implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable { public static final List SIGNATURES = ImmutableList.of( - FunctionSignature.ret(JsonType.INSTANCE).args(JsonType.INSTANCE, VarcharType.SYSTEM_DEFAULT), - FunctionSignature.ret(JsonType.INSTANCE).args(JsonType.INSTANCE, StringType.INSTANCE) + FunctionSignature.ret(JsonType.INSTANCE).varArgs(JsonType.INSTANCE, VarcharType.SYSTEM_DEFAULT), + FunctionSignature.ret(JsonType.INSTANCE).varArgs(JsonType.INSTANCE, StringType.INSTANCE) ); /** - * constructor with 2 arguments. + * constructor with 2 or more arguments. */ - public JsonbExtract(Expression arg0, Expression arg1) { - super("jsonb_extract", arg0, arg1); + public JsonbExtract(Expression arg0, Expression arg1, Expression... varArgs) { + super("jsonb_extract", ExpressionUtils.mergeArguments(arg0, arg1, varArgs)); } /** @@ -55,8 +56,9 @@ public JsonbExtract(Expression arg0, Expression arg1) { */ @Override public JsonbExtract withChildren(List children) { - Preconditions.checkArgument(children.size() == 2); - return new JsonbExtract(children.get(0), children.get(1)); + Preconditions.checkArgument(children.size() >= 2); + return new JsonbExtract(children.get(0), children.get(1), + children.subList(2, children.size()).toArray(new Expression[0])); } @Override diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbValid.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbValid.java new file mode 100644 index 000000000000000..220f3eeeb3168f6 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonbValid.java @@ -0,0 +1,70 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package org.apache.doris.nereids.trees.expressions.functions.scalar; + +import org.apache.doris.catalog.FunctionSignature; +import org.apache.doris.nereids.trees.expressions.Expression; +import org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable; +import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature; +import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression; +import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor; +import org.apache.doris.nereids.types.IntegerType; +import org.apache.doris.nereids.types.VarcharType; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * ScalarFunction 'jsonb_valid'. This class is generated by GenerateFunction. + */ +public class JsonbValid extends ScalarFunction + implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + + public static final List SIGNATURES = ImmutableList.of( + FunctionSignature.ret(IntegerType.INSTANCE).args(VarcharType.SYSTEM_DEFAULT) + ); + + /** + * constructor with 1 arguments. + */ + public JsonbValid(Expression arg0) { + super("json_valid", arg0); + } + + /** + * withChildren. + */ + @Override + public JsonbValid withChildren(List children) { + Preconditions.checkArgument(children.size() == 1); + return new JsonbValid(children.get(0)); + } + + @Override + public List getSignatures() { + return SIGNATURES; + } + + @Override + public R accept(ExpressionVisitor visitor, C context) { + return visitor.visitJsonbValid(this, context); + } +} + diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/visitor/ScalarFunctionVisitor.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/visitor/ScalarFunctionVisitor.java index 4f26f75b24927ac..0c7f0eaa01c1621 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/visitor/ScalarFunctionVisitor.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/visitor/ScalarFunctionVisitor.java @@ -193,6 +193,7 @@ import org.apache.doris.nereids.trees.expressions.functions.scalar.JsonbParseNullableErrorToNull; import org.apache.doris.nereids.trees.expressions.functions.scalar.JsonbParseNullableErrorToValue; import org.apache.doris.nereids.trees.expressions.functions.scalar.JsonbType; +import org.apache.doris.nereids.trees.expressions.functions.scalar.JsonbValid; import org.apache.doris.nereids.trees.expressions.functions.scalar.LastDay; import org.apache.doris.nereids.trees.expressions.functions.scalar.Least; import org.apache.doris.nereids.trees.expressions.functions.scalar.Left; @@ -1072,6 +1073,10 @@ default R visitJsonbParseNullableErrorToValue(JsonbParseNullableErrorToValue fun return visitScalarFunction(function, context); } + default R visitJsonbValid(JsonbValid jsonbValid, C context) { + return visitScalarFunction(jsonbValid, context); + } + default R visitJsonbType(JsonbType jsonbType, C context) { return visitScalarFunction(jsonbType, context); }