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

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

commit e7ea7fa6ef0d0f87a49ef691aecf3727e5d3d9c6
Author: Joe McDonnell <[email protected]>
AuthorDate: Fri Mar 21 12:33:06 2025 -0700

    IMPALA-13886: Fix order of recursion for complex types for tuple caching
    
    Queries that use complex types fail with an IllegalStateException
    when running with tuple caching. The issue is that the logic for
    registering tuples is recursing in the wrong order. It processes
    the parent before moving on to the child, but the parent references
    tuple id's in the child and cannot be processed first. This
    switches the ordering so that the children are processed first.
    
    Testing:
     - Added a sanity check for complex types in TupleCacheTest
    
    Change-Id: I853c06e76422382c628850181e3c7e4fdf86efc2
    Reviewed-on: http://gerrit.cloudera.org:8080/22667
    Reviewed-by: Impala Public Jenkins <[email protected]>
    Tested-by: Impala Public Jenkins <[email protected]>
---
 .../main/java/org/apache/impala/planner/TupleCacheInfo.java  | 12 +++++++-----
 .../test/java/org/apache/impala/planner/TupleCacheTest.java  |  5 +++++
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/fe/src/main/java/org/apache/impala/planner/TupleCacheInfo.java 
b/fe/src/main/java/org/apache/impala/planner/TupleCacheInfo.java
index 0e67524d3..2c8037ae7 100644
--- a/fe/src/main/java/org/apache/impala/planner/TupleCacheInfo.java
+++ b/fe/src/main/java/org/apache/impala/planner/TupleCacheInfo.java
@@ -344,16 +344,18 @@ public class TupleCacheInfo {
         // Assign a translated slot id and it to the map
         slotTranslationMap_.put(slotDesc.getId(), 
translatedSlotIdGenerator_.getNextId());
 
-        if (incorporateIntoHash) {
-           // Incorporate the SlotDescriptor into the hash
-          TSlotDescriptor thriftSlotDesc = slotDesc.toThrift(serialCtx);
-          hashThrift(thriftSlotDesc);
-        }
         // Slots can have nested tuples, so this can recurse. The depth is 
limited.
+        // The parent can reference tuple ids from children, so this needs to 
recurse
+        // to the children first.
         TupleDescriptor nestedTupleDesc = slotDesc.getItemTupleDesc();
         if (nestedTupleDesc != null) {
           registerTupleHelper(nestedTupleDesc.getId(), incorporateIntoHash);
         }
+        if (incorporateIntoHash) {
+           // Incorporate the SlotDescriptor into the hash
+          TSlotDescriptor thriftSlotDesc = slotDesc.toThrift(serialCtx);
+          hashThrift(thriftSlotDesc);
+        }
       }
     }
   }
diff --git a/fe/src/test/java/org/apache/impala/planner/TupleCacheTest.java 
b/fe/src/test/java/org/apache/impala/planner/TupleCacheTest.java
index 35963501d..f447d55fd 100644
--- a/fe/src/test/java/org/apache/impala/planner/TupleCacheTest.java
+++ b/fe/src/test/java/org/apache/impala/planner/TupleCacheTest.java
@@ -66,6 +66,11 @@ public class TupleCacheTest extends PlannerTestBase {
     // Different filter
     verifyDifferentCacheKeys("select id from functional.alltypes where id = 1",
         "select id from functional.alltypes where id = 2");
+
+    // Sanity check for complex types
+    verifyIdenticalCacheKeys(
+        "select nested_struct from functional_parquet.complextypestbl",
+        "select nested_struct from functional_parquet.complextypestbl");
   }
 
   @Test

Reply via email to