aboutsummaryrefslogtreecommitdiff
path: root/exec/java-exec/src/test/java/org
diff options
context:
space:
mode:
authorIgor Guzenko <ihor.huzenko.igs@gmail.com>2019-01-04 15:47:32 +0200
committerVitalii Diravka <vitalii.diravka@gmail.com>2019-01-18 17:52:55 +0200
commitde863afcd17447c3f2bb91a7ddd9f1c273a633a4 (patch)
tree6875f6fe5581714ea1d3142b766f4882741f0c63 /exec/java-exec/src/test/java/org
parent95d91f40c5991720b6f9d1cd2147edf58c8b136f (diff)
DRILL-6944: UnsupportedOperationException thrown for view over MapR-DB binary table
1. Added persistence of MAP key and value types in Drill views (affects .view.drill file) for avoiding cast problems in future. 2. Preserved backward compatibility of older view files by treating untyped maps as ANY. closes #1602
Diffstat (limited to 'exec/java-exec/src/test/java/org')
-rw-r--r--exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestBaseViewSupport.java4
-rw-r--r--exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestViewSupport.java61
2 files changed, 58 insertions, 7 deletions
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestBaseViewSupport.java b/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestBaseViewSupport.java
index adb253813..e9f7aabd5 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestBaseViewSupport.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestBaseViewSupport.java
@@ -17,8 +17,8 @@
*/
package org.apache.drill.exec.sql;
+import org.apache.drill.PlanTestBase;
import org.apache.drill.shaded.guava.com.google.common.base.Strings;
-import org.apache.drill.test.BaseTestQuery;
import org.apache.drill.test.TestBuilder;
import java.util.List;
@@ -28,7 +28,7 @@ import java.util.concurrent.atomic.AtomicInteger;
* Base class for view tests. It has utility methods which can be used when writing tests for views on tables
* in different storage engines such as Hive, HBase etc.
*/
-public class TestBaseViewSupport extends BaseTestQuery {
+public class TestBaseViewSupport extends PlanTestBase {
private static AtomicInteger viewSeqNum = new AtomicInteger(0);
/**
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestViewSupport.java b/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestViewSupport.java
index a0773bc95..a2eefcc40 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestViewSupport.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestViewSupport.java
@@ -17,19 +17,19 @@
*/
package org.apache.drill.exec.sql;
-import org.apache.drill.shaded.guava.com.google.common.collect.ImmutableList;
+import java.io.File;
+import java.nio.file.Paths;
+import java.util.List;
+
import org.apache.commons.io.FileUtils;
import org.apache.drill.categories.SqlTest;
import org.apache.drill.categories.UnlikelyTest;
+import org.apache.drill.shaded.guava.com.google.common.collect.ImmutableList;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-import java.io.File;
-import java.nio.file.Paths;
-import java.util.List;
-
import static org.apache.drill.exec.util.StoragePluginTestUtils.DFS_TMP_SCHEMA;
import static org.apache.drill.exec.util.StoragePluginTestUtils.TMP_SCHEMA;
@@ -39,6 +39,7 @@ public class TestViewSupport extends TestBaseViewSupport {
@BeforeClass
public static void setupTestFiles() {
dirTestWatcher.copyResourceToRoot(Paths.get("nation"));
+ dirTestWatcher.copyResourceToRoot(Paths.get("avro", "map_string_to_long.avro"));
}
@Test
@@ -800,4 +801,54 @@ public class TestViewSupport extends TestBaseViewSupport {
test("DROP VIEW IF EXISTS `%s`.`%s`", DFS_TMP_SCHEMA, viewName);
}
}
+
+ @Test // DRILL-6944
+ public void testSelectMapColumnOfNewlyCreatedView() throws Exception {
+ try {
+ test("CREATE VIEW dfs.tmp.`mapf_view` AS SELECT `mapf` FROM dfs.`avro/map_string_to_long.avro`");
+ test("SELECT * FROM dfs.tmp.`mapf_view`");
+ testBuilder()
+ .sqlQuery("SELECT `mapf`['ki'] as ki FROM dfs.tmp.`mapf_view`")
+ .unOrdered()
+ .baselineColumns("ki")
+ .baselineValues(1L)
+ .go();
+ } finally {
+ test("DROP VIEW IF EXISTS dfs.tmp.`mapf_view`");
+ }
+ }
+
+ @Test // DRILL-6944
+ public void testMapTypeFullyQualifiedInNewlyCreatedView() throws Exception {
+ try {
+ test("CREATE VIEW dfs.tmp.`mapf_view` AS SELECT `mapf` FROM dfs.`avro/map_string_to_long.avro`");
+ testPlanWithAttributesMatchingPatterns("SELECT * FROM dfs.tmp.`mapf_view`", new String[]{
+ "Screen : rowType = RecordType\\(\\(VARCHAR\\(65535\\), BIGINT\\) MAP mapf\\)",
+ "Project\\(mapf=\\[\\$0\\]\\) : rowType = RecordType\\(\\(VARCHAR\\(65535\\), BIGINT\\) MAP mapf\\)",
+ "Scan.*avro/map_string_to_long.avro.*rowType = RecordType\\(\\(VARCHAR\\(65535\\), BIGINT\\) MAP mapf\\)"
+ }, null);
+ } finally {
+ test("DROP VIEW IF EXISTS dfs.tmp.`mapf_view`");
+ }
+ }
+
+ @Test // DRILL-6944
+ public void testMapColumnOfOlderViewWithUntypedMap() throws Exception {
+ test("SELECT * FROM cp.`view/vw_before_drill_6944.view.drill`");
+ testBuilder()
+ .sqlQuery("SELECT `mapf`['ki'] as ki FROM cp.`view/vw_before_drill_6944.view.drill`")
+ .unOrdered()
+ .baselineColumns("ki")
+ .baselineValues(1L)
+ .go();
+ }
+
+ @Test // DRILL-6944
+ public void testMapTypeTreatedAsAnyInOlderViewWithUntypedMap() throws Exception {
+ testPlanWithAttributesMatchingPatterns("SELECT * FROM cp.`view/vw_before_drill_6944.view.drill`", new String[]{
+ "Screen : rowType = RecordType\\(ANY mapf\\)",
+ "Project.mapf=.CAST\\(\\$0\\):ANY NOT NULL.*"
+ }, null);
+ }
+
}