This is an automated email from the ASF dual-hosted git repository.
ihuzenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/drill.git
The following commit(s) were added to refs/heads/master by this push:
new 23db12c DRILL-7387: Failed to get value by int key from map nested
into struct
23db12c is described below
commit 23db12cdd57dd784b7e18b7600ef408698e3d3b1
Author: Igor Guzenko <[email protected]>
AuthorDate: Wed Sep 25 13:49:51 2019 +0300
DRILL-7387: Failed to get value by int key from map nested into struct
---
.../apache/drill/exec/hive/complex_types/TestHiveMaps.java | 12 ++++++++++++
.../drill/exec/hive/complex_types/TestHiveStructs.java | 12 ++++++++++++
.../java/org/apache/drill/exec/expr/EvaluationVisitor.java | 3 +++
3 files changed, 27 insertions(+)
diff --git
a/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/hive/complex_types/TestHiveMaps.java
b/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/hive/complex_types/TestHiveMaps.java
index 4598189..cb855ce 100644
---
a/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/hive/complex_types/TestHiveMaps.java
+++
b/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/hive/complex_types/TestHiveMaps.java
@@ -769,6 +769,18 @@ public class TestHiveMaps extends ClusterTest {
}
@Test
+ public void getByKeyP22() throws Exception {
+ testBuilder()
+ .sqlQuery("SELECT rid, mc.map_struct_map.z.m[3] p22 FROM
hive.map_complex_tbl mc")
+ .unOrdered()
+ .baselineColumns("rid", "p22")
+ .baselineValues(1, 2)
+ .baselineValues(2, null)
+ .baselineValues(3, 3)
+ .go();
+ }
+
+ @Test
public void countMapColumn() throws Exception {
testBuilder()
.sqlQuery("SELECT COUNT(int_string) AS cnt FROM hive.map_tbl")
diff --git
a/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/hive/complex_types/TestHiveStructs.java
b/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/hive/complex_types/TestHiveStructs.java
index a85e5c8..535ad70 100644
---
a/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/hive/complex_types/TestHiveStructs.java
+++
b/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/hive/complex_types/TestHiveStructs.java
@@ -442,4 +442,16 @@ public class TestHiveStructs extends ClusterTest {
.baselineValues(3, -2)
.go();
}
+
+ @Test // DRILL-7387
+ public void structWithMapByIntKey() throws Exception {
+ testBuilder()
+ .sqlQuery("SELECT rid, t.str_map.m[1] bk FROM hive.struct_tbl_p t")
+ .unOrdered()
+ .baselineColumns("rid", "bk")
+ .baselineValues(1, 0)
+ .baselineValues(2, 3)
+ .baselineValues(3, 4)
+ .go();
+ }
}
diff --git
a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/EvaluationVisitor.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/EvaluationVisitor.java
index a24b0bd..c3478f6 100644
---
a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/EvaluationVisitor.java
+++
b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/EvaluationVisitor.java
@@ -590,6 +590,9 @@ public class EvaluationVisitor {
depth++;
}
+ // expected that after loop depth at least equal to last id index
+ depth = Math.max(depth, e.getFieldId().getFieldIds().length - 1);
+
if (complex || repeated) {
if (e.getFieldId().isDict(depth)) {