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

yiguolei pushed a commit to branch branch-4.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-4.0 by this push:
     new 43e309e9fc5 branch-4.0: [feature](posexplode) support multi args 
#58990 (#59875)
43e309e9fc5 is described below

commit 43e309e9fc55d8d919231665e796b4185ed8b8b0
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Thu Jan 15 17:38:24 2026 +0800

    branch-4.0: [feature](posexplode) support multi args #58990 (#59875)
    
    Cherry-picked from #58990
    
    Co-authored-by: TengJianPing <[email protected]>
---
 .../catalog/BuiltinTableGeneratingFunctions.java   |   3 +-
 .../functions/generator/PosExplode.java            |  56 ++++++--
 .../functions/generator/PosExplodeOuter.java       |  55 +++++--
 .../functions/generator/PosExplodeOuterTest.java   |  73 ++++++++++
 .../functions/generator/PosExplodeTest.java        |  73 ++++++++++
 .../sql_functions/table_function/posexplode.out    | 159 +++++++++++++++------
 .../sql_functions/table_function/posexplode.groovy |  49 +++++++
 7 files changed, 398 insertions(+), 70 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/catalog/BuiltinTableGeneratingFunctions.java
 
b/fe/fe-core/src/main/java/org/apache/doris/catalog/BuiltinTableGeneratingFunctions.java
index 1d5d05c2d10..cec4807c8f2 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/catalog/BuiltinTableGeneratingFunctions.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/catalog/BuiltinTableGeneratingFunctions.java
@@ -86,7 +86,8 @@ public class BuiltinTableGeneratingFunctions implements 
FunctionHelper {
             
.add("explode_variant_array_outer").add("explode_json_array_int").add("explode_json_array_double")
             
.add("explode_json_array_string").add("explode_json_array_json").add("explode_json_array_int_outer")
             
.add("explode_json_array_double_outer").add("explode_json_array_string_outer")
-            
.add("explode_json_array_json_outer").add("explode_split").add("explode_split_outer").build();
+            
.add("explode_json_array_json_outer").add("explode_split").add("explode_split_outer")
+            .add("posexplode").add("posexplode_outer").build();
 
     public Set<String> getReturnManyColumnFunctions() {
         return RETURN_MULTI_COLUMNS_FUNCTIONS;
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/generator/PosExplode.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/generator/PosExplode.java
index 2e9f784de72..8ff2de6f7bf 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/generator/PosExplode.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/generator/PosExplode.java
@@ -20,10 +20,13 @@ package 
org.apache.doris.nereids.trees.expressions.functions.generator;
 import org.apache.doris.catalog.FunctionSignature;
 import org.apache.doris.nereids.exceptions.AnalysisException;
 import org.apache.doris.nereids.trees.expressions.Expression;
-import org.apache.doris.nereids.trees.expressions.functions.PropagateNullable;
-import org.apache.doris.nereids.trees.expressions.shape.UnaryExpression;
+import org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable;
+import org.apache.doris.nereids.trees.expressions.functions.ComputePrecision;
+import org.apache.doris.nereids.trees.expressions.functions.CustomSignature;
+import org.apache.doris.nereids.trees.expressions.functions.SearchSignature;
 import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
 import org.apache.doris.nereids.types.ArrayType;
+import org.apache.doris.nereids.types.DataType;
 import org.apache.doris.nereids.types.IntegerType;
 import org.apache.doris.nereids.types.StructField;
 import org.apache.doris.nereids.types.StructType;
@@ -31,6 +34,7 @@ import org.apache.doris.nereids.types.StructType;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableList;
 
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -38,13 +42,13 @@ import java.util.List;
  * pose column: 0, 1, 2
  * value column: 'a', 'b', 'c'
  */
-public class PosExplode extends TableGeneratingFunction implements 
UnaryExpression, PropagateNullable {
+public class PosExplode extends TableGeneratingFunction implements 
CustomSignature, ComputePrecision, AlwaysNullable {
 
     /**
-     * constructor with 1 argument.
+     * constructor with one or more arguments.
      */
-    public PosExplode(Expression arg) {
-        super("posexplode", arg);
+    public PosExplode(Expression[] args) {
+        super("posexplode", args);
     }
 
     /** constructor for withChildren and reuse signature */
@@ -63,23 +67,45 @@ public class PosExplode extends TableGeneratingFunction 
implements UnaryExpressi
 
     @Override
     public void checkLegalityBeforeTypeCoercion() {
-        if (!(child().getDataType() instanceof ArrayType)) {
-            throw new AnalysisException("only support array type for 
posexplode function but got "
-                    + child().getDataType());
+        for (Expression c : children) {
+            if (!(c.getDataType() instanceof ArrayType)) {
+                throw new AnalysisException("only support array type for 
posexplode function but got "
+                        + c.getDataType());
+            }
         }
     }
 
     @Override
-    public List<FunctionSignature> getSignatures() {
-        return ImmutableList.of(
-                FunctionSignature.ret(new StructType(ImmutableList.of(
-                        new StructField("pos", IntegerType.INSTANCE, false, 
""),
-                        new StructField("col", ((ArrayType) 
child().getDataType()).getItemType(), true, ""))))
-                        .args(child().getDataType()));
+    public FunctionSignature computePrecision(FunctionSignature signature) {
+        return signature;
+    }
+
+    @Override
+    public FunctionSignature customSignature() {
+        List<DataType> arguments = new ArrayList<>();
+        ImmutableList.Builder<StructField> structFields = 
ImmutableList.builder();
+        structFields.add(new StructField("pos", IntegerType.INSTANCE, false, 
""));
+        for (int i = 0; i < children.size(); i++) {
+            if (children.get(i).getDataType().isArrayType()) {
+                structFields.add(
+                    new StructField("col" + (i + 1),
+                        ((ArrayType) 
(children.get(i)).getDataType()).getItemType(), true, ""));
+                arguments.add(children.get(i).getDataType());
+            } else {
+                
SearchSignature.throwCanNotFoundFunctionException(this.getName(), 
getArguments());
+            }
+        }
+        StructType structType = new StructType(structFields.build());
+        return FunctionSignature.of(structType, arguments);
     }
 
     @Override
     public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
         return visitor.visitPosExplode(this, context);
     }
+
+    @Override
+    public FunctionSignature searchSignature(List<FunctionSignature> 
signatures) {
+        return super.searchSignature(signatures);
+    }
 }
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/generator/PosExplodeOuter.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/generator/PosExplodeOuter.java
index f3979904d93..c6e0deeef5f 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/generator/PosExplodeOuter.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/generator/PosExplodeOuter.java
@@ -21,9 +21,12 @@ import org.apache.doris.catalog.FunctionSignature;
 import org.apache.doris.nereids.exceptions.AnalysisException;
 import org.apache.doris.nereids.trees.expressions.Expression;
 import org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable;
-import org.apache.doris.nereids.trees.expressions.shape.UnaryExpression;
+import org.apache.doris.nereids.trees.expressions.functions.ComputePrecision;
+import org.apache.doris.nereids.trees.expressions.functions.CustomSignature;
+import org.apache.doris.nereids.trees.expressions.functions.SearchSignature;
 import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
 import org.apache.doris.nereids.types.ArrayType;
+import org.apache.doris.nereids.types.DataType;
 import org.apache.doris.nereids.types.IntegerType;
 import org.apache.doris.nereids.types.StructField;
 import org.apache.doris.nereids.types.StructType;
@@ -31,6 +34,7 @@ import org.apache.doris.nereids.types.StructType;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableList;
 
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -38,13 +42,14 @@ import java.util.List;
  * pose column: 0, 1, 2
  * value column: 'a', 'b', 'c'
  */
-public class PosExplodeOuter extends TableGeneratingFunction implements 
UnaryExpression, AlwaysNullable {
+public class PosExplodeOuter extends TableGeneratingFunction implements
+        CustomSignature, ComputePrecision, AlwaysNullable {
 
     /**
-     * constructor with 1 argument.
+     * constructor with one or more arguments.
      */
-    public PosExplodeOuter(Expression arg) {
-        super("posexplode_outer", arg);
+    public PosExplodeOuter(Expression[] args) {
+        super("posexplode_outer", args);
     }
 
     /** constructor for withChildren and reuse signature */
@@ -63,23 +68,45 @@ public class PosExplodeOuter extends 
TableGeneratingFunction implements UnaryExp
 
     @Override
     public void checkLegalityBeforeTypeCoercion() {
-        if (!(child().getDataType() instanceof ArrayType)) {
-            throw new AnalysisException("only support array type for 
posexplode_outer function but got "
-                    + child().getDataType());
+        for (Expression c : children) {
+            if (!(c.getDataType() instanceof ArrayType)) {
+                throw new AnalysisException("only support array type for 
posexplode_outer function but got "
+                        + c.getDataType());
+            }
         }
     }
 
     @Override
-    public List<FunctionSignature> getSignatures() {
-        return ImmutableList.of(
-                FunctionSignature.ret(new StructType(ImmutableList.of(
-                        new StructField("pos", IntegerType.INSTANCE, false, 
""),
-                        new StructField("col", ((ArrayType) 
child().getDataType()).getItemType(), true, ""))))
-                        .args(child().getDataType()));
+    public FunctionSignature computePrecision(FunctionSignature signature) {
+        return signature;
+    }
+
+    @Override
+    public FunctionSignature customSignature() {
+        List<DataType> arguments = new ArrayList<>();
+        ImmutableList.Builder<StructField> structFields = 
ImmutableList.builder();
+        structFields.add(new StructField("pos", IntegerType.INSTANCE, false, 
""));
+        for (int i = 0; i < children.size(); i++) {
+            if (children.get(i).getDataType().isArrayType()) {
+                structFields.add(
+                    new StructField("col" + (i + 1),
+                        ((ArrayType) 
(children.get(i)).getDataType()).getItemType(), true, ""));
+                arguments.add(children.get(i).getDataType());
+            } else {
+                
SearchSignature.throwCanNotFoundFunctionException(this.getName(), 
getArguments());
+            }
+        }
+        StructType structType = new StructType(structFields.build());
+        return FunctionSignature.of(structType, arguments);
     }
 
     @Override
     public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
         return visitor.visitPosExplodeOuter(this, context);
     }
+
+    @Override
+    public FunctionSignature searchSignature(List<FunctionSignature> 
signatures) {
+        return super.searchSignature(signatures);
+    }
 }
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/expressions/functions/generator/PosExplodeOuterTest.java
 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/expressions/functions/generator/PosExplodeOuterTest.java
new file mode 100644
index 00000000000..36447baba6f
--- /dev/null
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/expressions/functions/generator/PosExplodeOuterTest.java
@@ -0,0 +1,73 @@
+// 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.generator;
+
+import org.apache.doris.catalog.FunctionSignature;
+import org.apache.doris.nereids.exceptions.AnalysisException;
+import org.apache.doris.nereids.trees.expressions.Expression;
+import org.apache.doris.nereids.trees.expressions.SlotReference;
+import org.apache.doris.nereids.types.ArrayType;
+import org.apache.doris.nereids.types.IntegerType;
+import org.apache.doris.nereids.types.StringType;
+import org.apache.doris.nereids.types.StructType;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+import java.util.List;
+
+public class PosExplodeOuterTest {
+
+    /////////////////////////////////////////
+    // GetSignatures
+    /////////////////////////////////////////
+
+    @Test
+    public void testGetSignatures() {
+        // build posexplode_outer(array<int>, array<str>) expression
+        Expression[] args = {SlotReference.of("int", 
ArrayType.of(IntegerType.INSTANCE)),
+            SlotReference.of("str", ArrayType.of(StringType.INSTANCE))};
+        PosExplodeOuter explode = new PosExplodeOuter(args);
+
+        // check signature
+        List<FunctionSignature> signatures = explode.getSignatures();
+        Assertions.assertEquals(1, signatures.size());
+        FunctionSignature signature = signatures.get(0);
+        Assertions.assertEquals(2, signature.argumentsTypes.size());
+        Assertions.assertTrue(signature.argumentsTypes.get(0).isArrayType());
+        Assertions.assertTrue(((ArrayType) 
signature.argumentsTypes.get(0)).getItemType().isIntegerType());
+        Assertions.assertTrue(signature.argumentsTypes.get(1).isArrayType());
+        Assertions.assertTrue(((ArrayType) 
signature.argumentsTypes.get(1)).getItemType().isStringType());
+        Assertions.assertTrue(signature.returnType.isStructType());
+        StructType returnType = (StructType) signature.returnType;
+        Assertions.assertEquals(3, returnType.getFields().size());
+        Assertions.assertEquals(IntegerType.INSTANCE, 
returnType.getFields().get(0).getDataType());
+        Assertions.assertEquals(IntegerType.INSTANCE, 
returnType.getFields().get(1).getDataType());
+        Assertions.assertEquals(StringType.INSTANCE, 
returnType.getFields().get(2).getDataType());
+    }
+
+    @Test
+    public void testGetSignaturesWithInvalidArgument() {
+        // build posexplode_outer(int)
+        Expression[] args = { SlotReference.of("int", IntegerType.INSTANCE) };
+        PosExplodeOuter explode = new PosExplodeOuter(args);
+
+        Assertions.assertThrows(AnalysisException.class, 
explode::getSignatures);
+    }
+
+}
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/expressions/functions/generator/PosExplodeTest.java
 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/expressions/functions/generator/PosExplodeTest.java
new file mode 100644
index 00000000000..0009363ba71
--- /dev/null
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/expressions/functions/generator/PosExplodeTest.java
@@ -0,0 +1,73 @@
+// 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.generator;
+
+import org.apache.doris.catalog.FunctionSignature;
+import org.apache.doris.nereids.exceptions.AnalysisException;
+import org.apache.doris.nereids.trees.expressions.Expression;
+import org.apache.doris.nereids.trees.expressions.SlotReference;
+import org.apache.doris.nereids.types.ArrayType;
+import org.apache.doris.nereids.types.IntegerType;
+import org.apache.doris.nereids.types.StringType;
+import org.apache.doris.nereids.types.StructType;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+import java.util.List;
+
+public class PosExplodeTest {
+
+    /////////////////////////////////////////
+    // GetSignatures
+    /////////////////////////////////////////
+
+    @Test
+    public void testGetSignatures() {
+        // build posexplode(array<int>, array<str>) expression
+        Expression[] args = {SlotReference.of("int", 
ArrayType.of(IntegerType.INSTANCE)),
+            SlotReference.of("str", ArrayType.of(StringType.INSTANCE))};
+        PosExplode explode = new PosExplode(args);
+
+        // check signature
+        List<FunctionSignature> signatures = explode.getSignatures();
+        Assertions.assertEquals(1, signatures.size());
+        FunctionSignature signature = signatures.get(0);
+        Assertions.assertEquals(2, signature.argumentsTypes.size());
+        Assertions.assertTrue(signature.argumentsTypes.get(0).isArrayType());
+        Assertions.assertTrue(((ArrayType) 
signature.argumentsTypes.get(0)).getItemType().isIntegerType());
+        Assertions.assertTrue(signature.argumentsTypes.get(1).isArrayType());
+        Assertions.assertTrue(((ArrayType) 
signature.argumentsTypes.get(1)).getItemType().isStringType());
+        Assertions.assertTrue(signature.returnType.isStructType());
+        StructType returnType = (StructType) signature.returnType;
+        Assertions.assertEquals(3, returnType.getFields().size());
+        Assertions.assertEquals(IntegerType.INSTANCE, 
returnType.getFields().get(0).getDataType());
+        Assertions.assertEquals(IntegerType.INSTANCE, 
returnType.getFields().get(1).getDataType());
+        Assertions.assertEquals(StringType.INSTANCE, 
returnType.getFields().get(2).getDataType());
+    }
+
+    @Test
+    public void testGetSignaturesWithInvalidArgument() {
+        // build posexplode(int)
+        Expression[] args = { SlotReference.of("int", IntegerType.INSTANCE) };
+        PosExplode explode = new PosExplode(args);
+
+        Assertions.assertThrows(AnalysisException.class, 
explode::getSignatures);
+    }
+
+}
diff --git 
a/regression-test/data/nereids_p0/sql_functions/table_function/posexplode.out 
b/regression-test/data/nereids_p0/sql_functions/table_function/posexplode.out
index 3de4cdd83ee..e21701f6bae 100644
--- 
a/regression-test/data/nereids_p0/sql_functions/table_function/posexplode.out
+++ 
b/regression-test/data/nereids_p0/sql_functions/table_function/posexplode.out
@@ -209,46 +209,125 @@
 4      liuba   []      \N      \N
 
 -- !explode_sql_alias_multi2 --
-0      zhangsan        ["Chinese", "Math", "English"]  {"pos":0, 
"col":"Chinese"}      {"pos":0, "col":"Chinese"}
-0      zhangsan        ["Chinese", "Math", "English"]  {"pos":0, 
"col":"Chinese"}      {"pos":1, "col":"Math"}
-0      zhangsan        ["Chinese", "Math", "English"]  {"pos":0, 
"col":"Chinese"}      {"pos":2, "col":"English"}
-0      zhangsan        ["Chinese", "Math", "English"]  {"pos":1, "col":"Math"} 
{"pos":0, "col":"Chinese"}
-0      zhangsan        ["Chinese", "Math", "English"]  {"pos":1, "col":"Math"} 
{"pos":1, "col":"Math"}
-0      zhangsan        ["Chinese", "Math", "English"]  {"pos":1, "col":"Math"} 
{"pos":2, "col":"English"}
-0      zhangsan        ["Chinese", "Math", "English"]  {"pos":2, 
"col":"English"}      {"pos":0, "col":"Chinese"}
-0      zhangsan        ["Chinese", "Math", "English"]  {"pos":2, 
"col":"English"}      {"pos":1, "col":"Math"}
-0      zhangsan        ["Chinese", "Math", "English"]  {"pos":2, 
"col":"English"}      {"pos":2, "col":"English"}
-1      lisi    ["null"]        {"pos":0, "col":"null"} {"pos":0, "col":"null"}
-2      wangwu  ["88a", "90b", "96c"]   {"pos":0, "col":"88a"}  {"pos":0, 
"col":"88a"}
-2      wangwu  ["88a", "90b", "96c"]   {"pos":0, "col":"88a"}  {"pos":1, 
"col":"90b"}
-2      wangwu  ["88a", "90b", "96c"]   {"pos":0, "col":"88a"}  {"pos":2, 
"col":"96c"}
-2      wangwu  ["88a", "90b", "96c"]   {"pos":1, "col":"90b"}  {"pos":0, 
"col":"88a"}
-2      wangwu  ["88a", "90b", "96c"]   {"pos":1, "col":"90b"}  {"pos":1, 
"col":"90b"}
-2      wangwu  ["88a", "90b", "96c"]   {"pos":1, "col":"90b"}  {"pos":2, 
"col":"96c"}
-2      wangwu  ["88a", "90b", "96c"]   {"pos":2, "col":"96c"}  {"pos":0, 
"col":"88a"}
-2      wangwu  ["88a", "90b", "96c"]   {"pos":2, "col":"96c"}  {"pos":1, 
"col":"90b"}
-2      wangwu  ["88a", "90b", "96c"]   {"pos":2, "col":"96c"}  {"pos":2, 
"col":"96c"}
-3      lisi2   [null]  {"pos":0, "col":null}   {"pos":0, "col":null}
+0      zhangsan        ["Chinese", "Math", "English"]  {"pos":0, 
"col1":"Chinese"}     {"pos":0, "col1":"Chinese"}
+0      zhangsan        ["Chinese", "Math", "English"]  {"pos":0, 
"col1":"Chinese"}     {"pos":1, "col1":"Math"}
+0      zhangsan        ["Chinese", "Math", "English"]  {"pos":0, 
"col1":"Chinese"}     {"pos":2, "col1":"English"}
+0      zhangsan        ["Chinese", "Math", "English"]  {"pos":1, 
"col1":"Math"}        {"pos":0, "col1":"Chinese"}
+0      zhangsan        ["Chinese", "Math", "English"]  {"pos":1, 
"col1":"Math"}        {"pos":1, "col1":"Math"}
+0      zhangsan        ["Chinese", "Math", "English"]  {"pos":1, 
"col1":"Math"}        {"pos":2, "col1":"English"}
+0      zhangsan        ["Chinese", "Math", "English"]  {"pos":2, 
"col1":"English"}     {"pos":0, "col1":"Chinese"}
+0      zhangsan        ["Chinese", "Math", "English"]  {"pos":2, 
"col1":"English"}     {"pos":1, "col1":"Math"}
+0      zhangsan        ["Chinese", "Math", "English"]  {"pos":2, 
"col1":"English"}     {"pos":2, "col1":"English"}
+1      lisi    ["null"]        {"pos":0, "col1":"null"}        {"pos":0, 
"col1":"null"}
+2      wangwu  ["88a", "90b", "96c"]   {"pos":0, "col1":"88a"} {"pos":0, 
"col1":"88a"}
+2      wangwu  ["88a", "90b", "96c"]   {"pos":0, "col1":"88a"} {"pos":1, 
"col1":"90b"}
+2      wangwu  ["88a", "90b", "96c"]   {"pos":0, "col1":"88a"} {"pos":2, 
"col1":"96c"}
+2      wangwu  ["88a", "90b", "96c"]   {"pos":1, "col1":"90b"} {"pos":0, 
"col1":"88a"}
+2      wangwu  ["88a", "90b", "96c"]   {"pos":1, "col1":"90b"} {"pos":1, 
"col1":"90b"}
+2      wangwu  ["88a", "90b", "96c"]   {"pos":1, "col1":"90b"} {"pos":2, 
"col1":"96c"}
+2      wangwu  ["88a", "90b", "96c"]   {"pos":2, "col1":"96c"} {"pos":0, 
"col1":"88a"}
+2      wangwu  ["88a", "90b", "96c"]   {"pos":2, "col1":"96c"} {"pos":1, 
"col1":"90b"}
+2      wangwu  ["88a", "90b", "96c"]   {"pos":2, "col1":"96c"} {"pos":2, 
"col1":"96c"}
+3      lisi2   [null]  {"pos":0, "col1":null}  {"pos":0, "col1":null}
 
 -- !explode_sql_alias_multi3 --
-0      zhangsan        ["Chinese", "Math", "English"]  {"pos":0, 
"col":"Chinese"}      {"pos":0, "col":"Chinese"}
-0      zhangsan        ["Chinese", "Math", "English"]  {"pos":0, 
"col":"Chinese"}      {"pos":1, "col":"Math"}
-0      zhangsan        ["Chinese", "Math", "English"]  {"pos":0, 
"col":"Chinese"}      {"pos":2, "col":"English"}
-0      zhangsan        ["Chinese", "Math", "English"]  {"pos":1, "col":"Math"} 
{"pos":0, "col":"Chinese"}
-0      zhangsan        ["Chinese", "Math", "English"]  {"pos":1, "col":"Math"} 
{"pos":1, "col":"Math"}
-0      zhangsan        ["Chinese", "Math", "English"]  {"pos":1, "col":"Math"} 
{"pos":2, "col":"English"}
-0      zhangsan        ["Chinese", "Math", "English"]  {"pos":2, 
"col":"English"}      {"pos":0, "col":"Chinese"}
-0      zhangsan        ["Chinese", "Math", "English"]  {"pos":2, 
"col":"English"}      {"pos":1, "col":"Math"}
-0      zhangsan        ["Chinese", "Math", "English"]  {"pos":2, 
"col":"English"}      {"pos":2, "col":"English"}
-1      lisi    ["null"]        {"pos":0, "col":"null"} {"pos":0, "col":"null"}
-2      wangwu  ["88a", "90b", "96c"]   {"pos":0, "col":"88a"}  {"pos":0, 
"col":"88a"}
-2      wangwu  ["88a", "90b", "96c"]   {"pos":0, "col":"88a"}  {"pos":1, 
"col":"90b"}
-2      wangwu  ["88a", "90b", "96c"]   {"pos":0, "col":"88a"}  {"pos":2, 
"col":"96c"}
-2      wangwu  ["88a", "90b", "96c"]   {"pos":1, "col":"90b"}  {"pos":0, 
"col":"88a"}
-2      wangwu  ["88a", "90b", "96c"]   {"pos":1, "col":"90b"}  {"pos":1, 
"col":"90b"}
-2      wangwu  ["88a", "90b", "96c"]   {"pos":1, "col":"90b"}  {"pos":2, 
"col":"96c"}
-2      wangwu  ["88a", "90b", "96c"]   {"pos":2, "col":"96c"}  {"pos":0, 
"col":"88a"}
-2      wangwu  ["88a", "90b", "96c"]   {"pos":2, "col":"96c"}  {"pos":1, 
"col":"90b"}
-2      wangwu  ["88a", "90b", "96c"]   {"pos":2, "col":"96c"}  {"pos":2, 
"col":"96c"}
-3      lisi2   [null]  {"pos":0, "col":null}   {"pos":0, "col":null}
+0      zhangsan        ["Chinese", "Math", "English"]  {"pos":0, 
"col1":"Chinese"}     {"pos":0, "col1":"Chinese"}
+0      zhangsan        ["Chinese", "Math", "English"]  {"pos":0, 
"col1":"Chinese"}     {"pos":1, "col1":"Math"}
+0      zhangsan        ["Chinese", "Math", "English"]  {"pos":0, 
"col1":"Chinese"}     {"pos":2, "col1":"English"}
+0      zhangsan        ["Chinese", "Math", "English"]  {"pos":1, 
"col1":"Math"}        {"pos":0, "col1":"Chinese"}
+0      zhangsan        ["Chinese", "Math", "English"]  {"pos":1, 
"col1":"Math"}        {"pos":1, "col1":"Math"}
+0      zhangsan        ["Chinese", "Math", "English"]  {"pos":1, 
"col1":"Math"}        {"pos":2, "col1":"English"}
+0      zhangsan        ["Chinese", "Math", "English"]  {"pos":2, 
"col1":"English"}     {"pos":0, "col1":"Chinese"}
+0      zhangsan        ["Chinese", "Math", "English"]  {"pos":2, 
"col1":"English"}     {"pos":1, "col1":"Math"}
+0      zhangsan        ["Chinese", "Math", "English"]  {"pos":2, 
"col1":"English"}     {"pos":2, "col1":"English"}
+1      lisi    ["null"]        {"pos":0, "col1":"null"}        {"pos":0, 
"col1":"null"}
+2      wangwu  ["88a", "90b", "96c"]   {"pos":0, "col1":"88a"} {"pos":0, 
"col1":"88a"}
+2      wangwu  ["88a", "90b", "96c"]   {"pos":0, "col1":"88a"} {"pos":1, 
"col1":"90b"}
+2      wangwu  ["88a", "90b", "96c"]   {"pos":0, "col1":"88a"} {"pos":2, 
"col1":"96c"}
+2      wangwu  ["88a", "90b", "96c"]   {"pos":1, "col1":"90b"} {"pos":0, 
"col1":"88a"}
+2      wangwu  ["88a", "90b", "96c"]   {"pos":1, "col1":"90b"} {"pos":1, 
"col1":"90b"}
+2      wangwu  ["88a", "90b", "96c"]   {"pos":1, "col1":"90b"} {"pos":2, 
"col1":"96c"}
+2      wangwu  ["88a", "90b", "96c"]   {"pos":2, "col1":"96c"} {"pos":0, 
"col1":"88a"}
+2      wangwu  ["88a", "90b", "96c"]   {"pos":2, "col1":"96c"} {"pos":1, 
"col1":"90b"}
+2      wangwu  ["88a", "90b", "96c"]   {"pos":2, "col1":"96c"} {"pos":2, 
"col1":"96c"}
+3      lisi2   [null]  {"pos":0, "col1":null}  {"pos":0, "col1":null}
+
+-- !pos_exp_multi_args_all --
+1      jack    ["t1_a", "t1_b"]        ["t2_a", "t2_b", "t2_c"]
+2      tom     ["t1_c"]        ["t2_d", "t2_e"]
+3      mary    \N      ["t2_f"]
+4      lily    ["t1_d", "t1_e"]        \N
+5      alice   \N      \N
+
+-- !pos_exp_multi_args0 --
+1      jack    ["t1_a", "t1_b"]        ["t2_a", "t2_b", "t2_c"]        0       
t1_a    t2_a
+1      jack    ["t1_a", "t1_b"]        ["t2_a", "t2_b", "t2_c"]        1       
t1_b    t2_b
+1      jack    ["t1_a", "t1_b"]        ["t2_a", "t2_b", "t2_c"]        2       
\N      t2_c
+2      tom     ["t1_c"]        ["t2_d", "t2_e"]        0       t1_c    t2_d
+2      tom     ["t1_c"]        ["t2_d", "t2_e"]        1       \N      t2_e
+3      mary    \N      ["t2_f"]        0       \N      t2_f
+4      lily    ["t1_d", "t1_e"]        \N      0       t1_d    \N
+4      lily    ["t1_d", "t1_e"]        \N      1       t1_e    \N
+
+-- !pos_exp_multi_args1 --
+1      jack    ["t1_a", "t1_b"]        ["t2_a", "t2_b", "t2_c"]        
{"pos":0, "col1":"t1_a", "col2":"t2_a"}
+1      jack    ["t1_a", "t1_b"]        ["t2_a", "t2_b", "t2_c"]        
{"pos":1, "col1":"t1_b", "col2":"t2_b"}
+1      jack    ["t1_a", "t1_b"]        ["t2_a", "t2_b", "t2_c"]        
{"pos":2, "col1":null, "col2":"t2_c"}
+2      tom     ["t1_c"]        ["t2_d", "t2_e"]        {"pos":0, 
"col1":"t1_c", "col2":"t2_d"}
+2      tom     ["t1_c"]        ["t2_d", "t2_e"]        {"pos":1, "col1":null, 
"col2":"t2_e"}
+3      mary    \N      ["t2_f"]        {"pos":0, "col1":null, "col2":"t2_f"}
+4      lily    ["t1_d", "t1_e"]        \N      {"pos":0, "col1":"t1_d", 
"col2":null}
+4      lily    ["t1_d", "t1_e"]        \N      {"pos":1, "col1":"t1_e", 
"col2":null}
+
+-- !pos_exp_multi_args_outer0 --
+1      jack    ["t1_a", "t1_b"]        ["t2_a", "t2_b", "t2_c"]        0       
t1_a    t2_a
+1      jack    ["t1_a", "t1_b"]        ["t2_a", "t2_b", "t2_c"]        1       
t1_b    t2_b
+1      jack    ["t1_a", "t1_b"]        ["t2_a", "t2_b", "t2_c"]        2       
\N      t2_c
+2      tom     ["t1_c"]        ["t2_d", "t2_e"]        0       t1_c    t2_d
+2      tom     ["t1_c"]        ["t2_d", "t2_e"]        1       \N      t2_e
+3      mary    \N      ["t2_f"]        0       \N      t2_f
+4      lily    ["t1_d", "t1_e"]        \N      0       t1_d    \N
+4      lily    ["t1_d", "t1_e"]        \N      1       t1_e    \N
+5      alice   \N      \N      \N      \N      \N
+
+-- !pos_exp_multi_args_outer1 --
+1      jack    ["t1_a", "t1_b"]        ["t2_a", "t2_b", "t2_c"]        
{"pos":0, "col1":"t1_a", "col2":"t2_a"}
+1      jack    ["t1_a", "t1_b"]        ["t2_a", "t2_b", "t2_c"]        
{"pos":1, "col1":"t1_b", "col2":"t2_b"}
+1      jack    ["t1_a", "t1_b"]        ["t2_a", "t2_b", "t2_c"]        
{"pos":2, "col1":null, "col2":"t2_c"}
+2      tom     ["t1_c"]        ["t2_d", "t2_e"]        {"pos":0, 
"col1":"t1_c", "col2":"t2_d"}
+2      tom     ["t1_c"]        ["t2_d", "t2_e"]        {"pos":1, "col1":null, 
"col2":"t2_e"}
+3      mary    \N      ["t2_f"]        {"pos":0, "col1":null, "col2":"t2_f"}
+4      lily    ["t1_d", "t1_e"]        \N      {"pos":0, "col1":"t1_d", 
"col2":null}
+4      lily    ["t1_d", "t1_e"]        \N      {"pos":1, "col1":"t1_e", 
"col2":null}
+5      alice   \N      \N      \N
+
+-- !pos_exp_multi_args_multi_lateral0 --
+1      jack    ["t1_a", "t1_b"]        ["t2_a", "t2_b", "t2_c"]        0       
t1_a    t2_a    0       t1_a    t2_a
+1      jack    ["t1_a", "t1_b"]        ["t2_a", "t2_b", "t2_c"]        0       
t1_a    t2_a    1       t1_b    t2_b
+1      jack    ["t1_a", "t1_b"]        ["t2_a", "t2_b", "t2_c"]        0       
t1_a    t2_a    2       \N      t2_c
+1      jack    ["t1_a", "t1_b"]        ["t2_a", "t2_b", "t2_c"]        1       
t1_b    t2_b    0       t1_a    t2_a
+1      jack    ["t1_a", "t1_b"]        ["t2_a", "t2_b", "t2_c"]        1       
t1_b    t2_b    1       t1_b    t2_b
+1      jack    ["t1_a", "t1_b"]        ["t2_a", "t2_b", "t2_c"]        1       
t1_b    t2_b    2       \N      t2_c
+1      jack    ["t1_a", "t1_b"]        ["t2_a", "t2_b", "t2_c"]        2       
\N      t2_c    0       t1_a    t2_a
+1      jack    ["t1_a", "t1_b"]        ["t2_a", "t2_b", "t2_c"]        2       
\N      t2_c    1       t1_b    t2_b
+1      jack    ["t1_a", "t1_b"]        ["t2_a", "t2_b", "t2_c"]        2       
\N      t2_c    2       \N      t2_c
+2      tom     ["t1_c"]        ["t2_d", "t2_e"]        0       t1_c    t2_d    
0       t1_c    t2_d
+2      tom     ["t1_c"]        ["t2_d", "t2_e"]        0       t1_c    t2_d    
1       \N      t2_e
+2      tom     ["t1_c"]        ["t2_d", "t2_e"]        1       \N      t2_e    
0       t1_c    t2_d
+2      tom     ["t1_c"]        ["t2_d", "t2_e"]        1       \N      t2_e    
1       \N      t2_e
+
+-- !pos_exp_multi_args_multi_lateral1 --
+1      jack    ["t1_a", "t1_b"]        ["t2_a", "t2_b", "t2_c"]        
{"pos":0, "col1":"t1_a", "col2":"t2_a"} {"pos":0, "col1":"t1_a", "col2":"t2_a"}
+1      jack    ["t1_a", "t1_b"]        ["t2_a", "t2_b", "t2_c"]        
{"pos":0, "col1":"t1_a", "col2":"t2_a"} {"pos":1, "col1":"t1_b", "col2":"t2_b"}
+1      jack    ["t1_a", "t1_b"]        ["t2_a", "t2_b", "t2_c"]        
{"pos":0, "col1":"t1_a", "col2":"t2_a"} {"pos":2, "col1":null, "col2":"t2_c"}
+1      jack    ["t1_a", "t1_b"]        ["t2_a", "t2_b", "t2_c"]        
{"pos":1, "col1":"t1_b", "col2":"t2_b"} {"pos":0, "col1":"t1_a", "col2":"t2_a"}
+1      jack    ["t1_a", "t1_b"]        ["t2_a", "t2_b", "t2_c"]        
{"pos":1, "col1":"t1_b", "col2":"t2_b"} {"pos":1, "col1":"t1_b", "col2":"t2_b"}
+1      jack    ["t1_a", "t1_b"]        ["t2_a", "t2_b", "t2_c"]        
{"pos":1, "col1":"t1_b", "col2":"t2_b"} {"pos":2, "col1":null, "col2":"t2_c"}
+1      jack    ["t1_a", "t1_b"]        ["t2_a", "t2_b", "t2_c"]        
{"pos":2, "col1":null, "col2":"t2_c"}   {"pos":0, "col1":"t1_a", "col2":"t2_a"}
+1      jack    ["t1_a", "t1_b"]        ["t2_a", "t2_b", "t2_c"]        
{"pos":2, "col1":null, "col2":"t2_c"}   {"pos":1, "col1":"t1_b", "col2":"t2_b"}
+1      jack    ["t1_a", "t1_b"]        ["t2_a", "t2_b", "t2_c"]        
{"pos":2, "col1":null, "col2":"t2_c"}   {"pos":2, "col1":null, "col2":"t2_c"}
+2      tom     ["t1_c"]        ["t2_d", "t2_e"]        {"pos":0, 
"col1":"t1_c", "col2":"t2_d"} {"pos":0, "col1":"t1_c", "col2":"t2_d"}
+2      tom     ["t1_c"]        ["t2_d", "t2_e"]        {"pos":0, 
"col1":"t1_c", "col2":"t2_d"} {"pos":1, "col1":null, "col2":"t2_e"}
+2      tom     ["t1_c"]        ["t2_d", "t2_e"]        {"pos":1, "col1":null, 
"col2":"t2_e"}   {"pos":0, "col1":"t1_c", "col2":"t2_d"}
+2      tom     ["t1_c"]        ["t2_d", "t2_e"]        {"pos":1, "col1":null, 
"col2":"t2_e"}   {"pos":1, "col1":null, "col2":"t2_e"}
 
diff --git 
a/regression-test/suites/nereids_p0/sql_functions/table_function/posexplode.groovy
 
b/regression-test/suites/nereids_p0/sql_functions/table_function/posexplode.groovy
index e29b9267743..3a7c69396fb 100644
--- 
a/regression-test/suites/nereids_p0/sql_functions/table_function/posexplode.groovy
+++ 
b/regression-test/suites/nereids_p0/sql_functions/table_function/posexplode.groovy
@@ -83,4 +83,53 @@ suite("posexplode") {
     sql """ set batch_size = 1; """
     order_qt_explode_sql_alias_multi3 """ select * from table_test_not lateral 
view posexplode(score) tmp as e1 lateral view posexplode(score) tmp2 as e2 
order by id;"""
 
+    sql """ DROP TABLE IF EXISTS test_posexplode_multi_args"""
+    sql """
+        CREATE TABLE `test_posexplode_multi_args`(
+                   `id` INT NULL,
+                   `name` TEXT NULL,
+                   `tags1` array<string> NULL,
+                   `tags2` array<string> NULL
+                 )  PROPERTIES ("replication_num" = "1");
+    """
+    sql """
+    insert into test_posexplode_multi_args values
+      (1, "jack", ["t1_a","t1_b"], ["t2_a","t2_b","t2_c"]),
+      (2, "tom",  ["t1_c"],        ["t2_d","t2_e"]),
+      (3, "mary", null,            ["t2_f"]),
+      (4, "lily", ["t1_d","t1_e"], null),
+      (5, "alice", null, null);
+    """
+    order_qt_pos_exp_multi_args_all """
+    select * from test_posexplode_multi_args;
+    """
+    order_qt_pos_exp_multi_args0 """
+    select id, name, tags1, tags2, k1, k2, k3 from test_posexplode_multi_args
+      lateral view posexplode(tags1, tags2) tmp1 as k1, k2, k3 order by 1, 2;
+    """
+    order_qt_pos_exp_multi_args1 """
+    select id, name, tags1, tags2, s1 from test_posexplode_multi_args
+      lateral view posexplode(tags1, tags2) tmp1 as s1 order by 1, 2;
+    """
+    order_qt_pos_exp_multi_args_outer0 """
+    select id, name, tags1, tags2, k1, k2, k3 from test_posexplode_multi_args
+      lateral view posexplode_outer(tags1, tags2) tmp1 as k1, k2, k3 order by 
1, 2;
+    """
+    order_qt_pos_exp_multi_args_outer1 """
+    select id, name, tags1, tags2, s1 from test_posexplode_multi_args
+      lateral view posexplode_outer(tags1, tags2) tmp1 as s1 order by 1, 2;
+    """
+
+    order_qt_pos_exp_multi_args_multi_lateral0 """
+    select id,name,tags1,tags2, k1, k2, k3, k4, k5, k6 from 
test_posexplode_multi_args
+      lateral view posexplode(non_nullable(tags1), non_nullable(tags2)) tmp as 
k1,k2,k3
+      lateral view posexplode_outer(tags1, tags2) tmp as k4,k5,k6
+    where tags1 is not null and tags2 is not null order by 1,2;
+    """
+    order_qt_pos_exp_multi_args_multi_lateral1 """
+    select id,name,tags1,tags2, s1, s2 from test_posexplode_multi_args
+      lateral view posexplode(non_nullable(tags1), non_nullable(tags2)) tmp as 
s1
+      lateral view posexplode_outer(tags1, tags2) tmp as s2
+    where tags1 is not null and tags2 is not null order by 1,2;
+    """
 }


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


Reply via email to