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

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

commit b7f17ea882062bba0a7cfe595b32921c613c0d60
Author: 924060929 <[email protected]>
AuthorDate: Wed Oct 29 11:17:41 2025 +0800

    fix "Index 2 out of bounds for length 2" when use tvf
---
 .../java/org/apache/doris/datasource/FileScanNode.java     | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/FileScanNode.java 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/FileScanNode.java
index 05a843f0b6c..f1205069e7c 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/FileScanNode.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/FileScanNode.java
@@ -50,6 +50,7 @@ import com.google.common.base.Preconditions;
 import com.google.common.collect.ArrayListMultimap;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
 import com.google.common.collect.Multimap;
 
 import java.util.Collections;
@@ -212,10 +213,12 @@ public abstract class FileScanNode extends 
ExternalScanNode {
         TExpr tExpr = new TExpr();
         tExpr.setNodes(Lists.newArrayList());
 
-        int index = 0;
-        List<SlotDescriptor> slots = desc.getSlots();
+        Map<String, SlotDescriptor> nameToSlotDesc = Maps.newLinkedHashMap();
+        for (SlotDescriptor slot : desc.getSlots()) {
+            nameToSlotDesc.put(slot.getColumn().getName(), slot);
+        }
+
         for (Column column : getColumns()) {
-            SlotDescriptor slotDescriptor = slots.get(index++);
             Expr expr;
             Expression expression;
             if (column.getDefaultValue() != null) {
@@ -230,9 +233,12 @@ public abstract class FileScanNode extends 
ExternalScanNode {
                     if (useVarcharAsNull) {
                         expression = new 
NullLiteral(VarcharType.SYSTEM_DEFAULT);
                     } else {
+                        SlotDescriptor slotDescriptor = 
nameToSlotDesc.get(column.getName());
                         // the nested type(map/array/struct) maybe pruned,
                         // we should use the pruned type to avoid be core
-                        expression = new 
NullLiteral(DataType.fromCatalogType(slotDescriptor.getType()));
+                        expression = new NullLiteral(DataType.fromCatalogType(
+                                slotDescriptor == null ? column.getType() : 
slotDescriptor.getType()
+                        ));
                     }
                 } else {
                     expression = null;


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

Reply via email to