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

csun5285 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 5ff34855dd2 [fix](function) keep struct_element as an alias of 
element_at (#64261)
5ff34855dd2 is described below

commit 5ff34855dd2416a02631d2113d4b09b7822a0f2f
Author: Chenyang Sun <[email protected]>
AuthorDate: Tue Jun 9 16:13:20 2026 +0800

    [fix](function) keep struct_element as an alias of element_at (#64261)
    
    #64027 merged struct_element into element_at and removed the
    struct_element function entirely. Users upgrading from an older version
    whose SQL / views still reference struct_element then fail with
    "function not found".
---
 .../function/array/function_array_element.cpp      |  2 ++
 .../doris/catalog/BuiltinScalarFunctions.java      |  3 +-
 .../struct_functions/test_struct_functions.out     | 32 ++++++++++++++++++++++
 .../struct_functions/test_struct_functions.groovy  |  7 +++++
 4 files changed, 43 insertions(+), 1 deletion(-)

diff --git a/be/src/exprs/function/array/function_array_element.cpp 
b/be/src/exprs/function/array/function_array_element.cpp
index 06521b19edf..9545c46f2e5 100644
--- a/be/src/exprs/function/array/function_array_element.cpp
+++ b/be/src/exprs/function/array/function_array_element.cpp
@@ -24,6 +24,8 @@ namespace doris {
 void register_function_array_element(SimpleFunctionFactory& factory) {
     factory.register_function<FunctionArrayElement>();
     factory.register_alias(FunctionArrayElement::name, "%element_extract%");
+    // struct_element was merged into element_at in #64027; keep it as an alias
+    factory.register_alias(FunctionArrayElement::name, "struct_element");
 }
 
 } // namespace doris
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 35e9a8cde02..9585a5d4386 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
@@ -774,7 +774,8 @@ public class BuiltinScalarFunctions implements 
FunctionHelper {
             scalar(Dround.class, "dround"),
             scalar(Dsqrt.class, "dsqrt"),
             scalar(E.class, "e"),
-            scalar(ElementAt.class, "element_at"),
+            // struct_element was merged into element_at in #64027; keep it as 
an alias
+            scalar(ElementAt.class, "element_at", "struct_element"),
             scalar(Elt.class, "elt"),
             scalar(Embed.class, "embed"),
             scalar(EncodeAsSmallInt.class, "encode_as_smallint"),
diff --git 
a/regression-test/data/query_p0/sql_functions/struct_functions/test_struct_functions.out
 
b/regression-test/data/query_p0/sql_functions/struct_functions/test_struct_functions.out
index f476524c142..ede744250e7 100644
--- 
a/regression-test/data/query_p0/sql_functions/struct_functions/test_struct_functions.out
+++ 
b/regression-test/data/query_p0/sql_functions/struct_functions/test_struct_functions.out
@@ -39,6 +39,38 @@ a    \N      abc
 \N     \N      \N
 NULL   null    \N
 
+-- !select_struct_element_alias_1 --
+1      2       3       4       5
+1      1000    10000000        100000000000    100000000000
+5      4       3       2       1
+1      \N      3       \N      5
+\N     \N      \N      \N      \N
+\N     \N      \N      \N      \N
+
+-- !select_struct_element_alias_2 --
+1.0    3.33    0.001
+1.0    2.143   0.001
+2.3    23.3    0.333
+2.0    \N      0.001
+\N     \N      \N
+\N     \N      \N
+
+-- !select_struct_element_alias_3 --
+2023-04-01     2023-04-01T12:00        2023-04-01      2023-04-01T12:00:01
+2023-04-01     2023-04-01T12:00        2023-04-01      2023-04-01T12:00:01
+2023-04-01     2023-04-01T12:00        2023-04-01      2023-04-01T12:00:01
+2023-04-01     \N      2023-04-01      \N
+\N     \N      \N      \N
+\N     \N      \N      \N
+
+-- !select_struct_element_alias_4 --
+a      abc     abc
+hi     doris   hello doris
+a      abc     abc
+a      \N      abc
+\N     \N      \N
+NULL   null    \N
+
 -- !select_struct_subscript_1 --
 1      2       3       4       5
 1      1000    10000000        100000000000    100000000000
diff --git 
a/regression-test/suites/query_p0/sql_functions/struct_functions/test_struct_functions.groovy
 
b/regression-test/suites/query_p0/sql_functions/struct_functions/test_struct_functions.groovy
index a652d97c3fb..a3243ccc3ed 100644
--- 
a/regression-test/suites/query_p0/sql_functions/struct_functions/test_struct_functions.groovy
+++ 
b/regression-test/suites/query_p0/sql_functions/struct_functions/test_struct_functions.groovy
@@ -48,6 +48,13 @@ suite("test_struct_functions") {
     qt_select_element_at_3 "SELECT 
element_at(k4,1),element_at(k4,2),element_at(k4,3),element_at(k4,4) FROM 
${tableName} ORDER BY k1"
     qt_select_element_at_4 "SELECT 
element_at(k5,1),element_at(k5,2),element_at(k5,3) FROM ${tableName} ORDER BY 
k1"
 
+    // #64027: struct_element was merged into element_at. It is kept as an 
alias of element_at so old
+    // SQL/views still work after upgrade; these must return exactly the same 
as the element_at cases.
+    qt_select_struct_element_alias_1 "SELECT 
struct_element(k2,'f1'),struct_element(k2,'f2'),struct_element(k2,'f3'),struct_element(k2,'f4'),struct_element(k2,'f5')
 FROM ${tableName} ORDER BY k1"
+    qt_select_struct_element_alias_2 "SELECT 
struct_element(k3,'f1'),struct_element(k3,'f2'),struct_element(k3,'f3') FROM 
${tableName} ORDER BY k1"
+    qt_select_struct_element_alias_3 "SELECT 
struct_element(k4,1),struct_element(k4,2),struct_element(k4,3),struct_element(k4,4)
 FROM ${tableName} ORDER BY k1"
+    qt_select_struct_element_alias_4 "SELECT 
struct_element(k5,1),struct_element(k5,2),struct_element(k5,3) FROM 
${tableName} ORDER BY k1"
+
     // DORIS-26105: subscript syntax `s['field']` / `s[index]` on STRUCT 
should work the same as
     // element_at and must not crash the BE (especially for NULL struct rows).
     qt_select_struct_subscript_1 "SELECT 
k2['f1'],k2['f2'],k2['f3'],k2['f4'],k2['f5'] FROM ${tableName} ORDER BY k1"


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

Reply via email to