This is an automated email from the ASF dual-hosted git repository.

mrhhsg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new e51099a9389 [fix](fe) Treat json_extract_no_quotes as 
json_extract_string alias (#65380)
e51099a9389 is described below

commit e51099a9389690784a96e221f74d69bbfee35e73
Author: Jerry Hu <[email protected]>
AuthorDate: Tue Jul 21 09:56:03 2026 +0800

    [fix](fe) Treat json_extract_no_quotes as json_extract_string alias (#65380)
    
    ### What problem does this PR solve?
    
    Issue Number: None
    
    Related PR: None
    
    Problem Summary: `json_extract_no_quotes` had a separate FE Nereids
    function definition, so it did not share the same FE binding and rewrite
    behavior as `json_extract_string`. This changes FE builtin function
    registration so `json_extract_no_quotes` resolves through the existing
    `JsonbExtractString` implementation, making it an alias of
    `json_extract_string`. Regression expectations are updated for the alias
    semantics.
    
    ### Release note
    
    `json_extract_no_quotes` is treated as an alias of `json_extract_string`
    in FE.
    
    ### Check List (For Author)
    
    - Test:
    - FE UT: `./run-fe-ut.sh --run
    org.apache.doris.nereids.rules.analysis.BindFunctionTest`
    - Build: `doris-local-regression --network 10.26.20.3/24 all -d
    doc/sql-manual/sql-functions -s doc_json_functions_test -forceGenOut`
    - Regression test: `doris-local-regression --network 10.26.20.3/24 run
    -d doc/sql-manual/sql-functions -s doc_json_functions_test`
    - Regression test: `doris-local-regression --network 10.26.20.3/24 run
    -d query_p0/sql_functions/json_functions -s test_json_function`
        - Code check: `git diff --check`
    - Behavior changed: Yes. `json_extract_no_quotes` now follows
    `json_extract_string` FE semantics.
    - Does this need documentation: No
---
 .../doris/catalog/BuiltinScalarFunctions.java      |  5 +-
 .../functions/scalar/JsonExtractNoQuotes.java      | 74 ----------------------
 .../expressions/visitor/ScalarFunctionVisitor.java |  5 --
 .../sql-functions/doc_json_functions_test.out      |  2 +-
 .../json_functions/test_json_function.out          | 11 +---
 .../json_functions/test_json_function.groovy       |  9 +--
 6 files changed, 9 insertions(+), 97 deletions(-)

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 af6a32e993c..3b1171a376c 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
@@ -286,7 +286,6 @@ import 
org.apache.doris.nereids.trees.expressions.functions.scalar.IsValidUtf8;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.JsonArray;
 import 
org.apache.doris.nereids.trees.expressions.functions.scalar.JsonArrayIgnoreNull;
 import 
org.apache.doris.nereids.trees.expressions.functions.scalar.JsonContains;
-import 
org.apache.doris.nereids.trees.expressions.functions.scalar.JsonExtractNoQuotes;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.JsonHash;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.JsonInsert;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.JsonKeys;
@@ -864,7 +863,6 @@ public class BuiltinScalarFunctions implements 
FunctionHelper {
             scalar(JsonObjectFlatten.class, "json_object_flatten"),
             scalar(JsonQuote.class, "json_quote"),
             scalar(JsonUnQuote.class, "json_unquote"),
-            scalar(JsonExtractNoQuotes.class, "json_extract_no_quotes"),
             scalar(JsonHash.class, "json_hash"),
             scalar(JsonHash.class, "jsonb_hash"),
             scalar(JsonInsert.class, "json_insert", "jsonb_insert"),
@@ -881,7 +879,8 @@ public class BuiltinScalarFunctions implements 
FunctionHelper {
             scalar(JsonbExtractInt.class, "jsonb_extract_int", 
"json_extract_int", "get_json_int"),
             scalar(JsonbExtractIsnull.class, "json_extract_isnull"),
             scalar(JsonbExtractIsnull.class, "jsonb_extract_isnull"),
-            scalar(JsonbExtractString.class, "jsonb_extract_string", 
"json_extract_string", "get_json_string"),
+            scalar(JsonbExtractString.class, "jsonb_extract_string", 
"json_extract_string",
+                    "json_extract_no_quotes", "get_json_string"),
             scalar(JsonbParse.class, "jsonb_parse", "json_parse"),
             scalar(JsonbParseErrorToNull.class, "jsonb_parse_error_to_null", 
"json_parse_error_to_null"),
             scalar(JsonbParseErrorToValue.class, "jsonb_parse_error_to_value", 
"json_parse_error_to_value"),
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonExtractNoQuotes.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonExtractNoQuotes.java
deleted file mode 100644
index 02efc44c964..00000000000
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/JsonExtractNoQuotes.java
+++ /dev/null
@@ -1,74 +0,0 @@
-// 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.visitor.ExpressionVisitor;
-import org.apache.doris.nereids.types.JsonType;
-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;
-
-import java.util.List;
-
-/**
- * ScalarFunction 'json_object'.
- */
-public class JsonExtractNoQuotes extends ScalarFunction
-        implements ExplicitlyCastableSignature, AlwaysNullable {
-
-    public static final List<FunctionSignature> SIGNATURES =
-            ImmutableList.of(FunctionSignature.ret(JsonType.INSTANCE)
-                    .varArgs(JsonType.INSTANCE, VarcharType.SYSTEM_DEFAULT));
-
-    /**
-     * constructor with 1 or more arguments.
-     */
-    public JsonExtractNoQuotes(Expression arg0, Expression arg1, Expression... 
varArgs) {
-        super("json_extract_no_quotes", ExpressionUtils.mergeArguments(arg0, 
arg1, varArgs));
-    }
-
-    /** constructor for withChildren and reuse signature */
-    private JsonExtractNoQuotes(ScalarFunctionParams functionParams) {
-        super(functionParams);
-    }
-
-    /**
-     * withChildren.
-     */
-    @Override
-    public JsonExtractNoQuotes withChildren(List<Expression> children) {
-        Preconditions.checkArgument(children.size() >= 2);
-        return new JsonExtractNoQuotes(getFunctionParams(children));
-    }
-
-    @Override
-    public List<FunctionSignature> getSignatures() {
-        return SIGNATURES;
-    }
-
-    @Override
-    public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
-        return visitor.visitJsonExtractNoQuotes(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 68afa81f4fd..7b1724ae085 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
@@ -305,7 +305,6 @@ import 
org.apache.doris.nereids.trees.expressions.functions.scalar.IsValidUtf8;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.JsonArray;
 import 
org.apache.doris.nereids.trees.expressions.functions.scalar.JsonArrayIgnoreNull;
 import 
org.apache.doris.nereids.trees.expressions.functions.scalar.JsonContains;
-import 
org.apache.doris.nereids.trees.expressions.functions.scalar.JsonExtractNoQuotes;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.JsonHash;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.JsonInsert;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.JsonKeys;
@@ -1748,10 +1747,6 @@ public interface ScalarFunctionVisitor<R, C> {
         return visitScalarFunction(jsonObjectFlatten, context);
     }
 
-    default R visitJsonExtractNoQuotes(JsonExtractNoQuotes jsonExtract, C 
context) {
-        return visitScalarFunction(jsonExtract, context);
-    }
-
     default R visitJsonHash(JsonHash jsonhash, C context) {
         return visitScalarFunction(jsonhash, context);
     }
diff --git 
a/regression-test/data/doc/sql-manual/sql-functions/doc_json_functions_test.out 
b/regression-test/data/doc/sql-manual/sql-functions/doc_json_functions_test.out
index cfa805f9584..e55d98e4178 100644
--- 
a/regression-test/data/doc/sql-manual/sql-functions/doc_json_functions_test.out
+++ 
b/regression-test/data/doc/sql-manual/sql-functions/doc_json_functions_test.out
@@ -45,7 +45,7 @@
 ["v1",6.6,[1,2],2]
 
 -- !json_extract_no_quotes --
-"doris"
+doris
 
 -- !json_extract_isnull --
 false
diff --git 
a/regression-test/data/query_p0/sql_functions/json_functions/test_json_function.out
 
b/regression-test/data/query_p0/sql_functions/json_functions/test_json_function.out
index 21129e5247a..6a69d5c8712 100644
--- 
a/regression-test/data/query_p0/sql_functions/json_functions/test_json_function.out
+++ 
b/regression-test/data/query_p0/sql_functions/json_functions/test_json_function.out
@@ -164,20 +164,11 @@ true      \N
 2
 
 -- !sql --
-"doris"
-
--- !sql --
-\N
+doris
 
 -- !sql --
 \N
 
--- !sql --
-["v1",{"k21":6.6,"k22":[1,2,3]}]
-
--- !sql --
-[6.6,[1,2,3],2]
-
 -- !sql --
 123
 
diff --git 
a/regression-test/suites/query_p0/sql_functions/json_functions/test_json_function.groovy
 
b/regression-test/suites/query_p0/sql_functions/json_functions/test_json_function.groovy
index eec99e21782..baed2ba4324 100644
--- 
a/regression-test/suites/query_p0/sql_functions/json_functions/test_json_function.groovy
+++ 
b/regression-test/suites/query_p0/sql_functions/json_functions/test_json_function.groovy
@@ -83,10 +83,11 @@ suite("test_json_function", "arrow_flight_sql") {
 
     qt_sql "SELECT json_extract_no_quotes('[1, 2, 3]', '\$.[1]');"
     qt_sql "SELECT json_extract_no_quotes('{\"id\": 123, \"name\": 
\"doris\"}', '\$.name');"
-    qt_sql "SELECT json_extract_no_quotes('{\"id\": 123, \"name\": 
\"doris\"}', '\$.id', null);"
     qt_sql "SELECT json_extract_no_quotes(null, '\$.id');"
-    qt_sql "SELECT json_extract_no_quotes('{\"k1\": \"v1\", \"k2\": { \"k21\": 
6.6, \"k22\": [1, 2, 3] } }', '\$.k1', '\$.k2');"
-    qt_sql "SELECT json_extract_no_quotes('{\"k1\": \"v1\", \"k2\": { \"k21\": 
6.6, \"k22\": [1, 2, 3] } }', '\$.k2.k21', '\$.k2.k22', '\$.k2.k22[1]');"
+    test {
+        sql "SELECT json_extract_no_quotes('{\"id\": 123, \"name\": 
\"doris\"}', '\$.id', null);"
+        exception "Can not found function 'json_extract_no_quotes' which has 3 
arity"
+    }
 
     // invalid json path
     qt_sql """select get_json_string('{"name\\k" : 123}', '\$.name\\k')"""
@@ -317,4 +318,4 @@ suite("test_json_function", "arrow_flight_sql") {
     """
 
     sql "drop table if exists json_remove_test_table;"
-}
\ No newline at end of file
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to