ihuzenko commented on a change in pull request #1559: DRILL-540: Allow querying 
hive views in Drill
URL: https://github.com/apache/drill/pull/1559#discussion_r242183460
 
 

 ##########
 File path: 
contrib/storage-hive/core/src/test/java/org/apache/drill/exec/hive/TestHiveViewsSupport.java
 ##########
 @@ -0,0 +1,232 @@
+/*
+ * 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.drill.exec.hive;
+
+import java.math.BigDecimal;
+
+import org.apache.drill.categories.HiveStorageTest;
+import org.apache.drill.categories.SlowTest;
+import org.apache.drill.exec.ExecConstants;
+import org.apache.drill.exec.expr.fn.impl.DateUtility;
+import org.apache.drill.exec.planner.physical.PlannerSettings;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import static org.junit.Assert.assertEquals;
+
+@Category({SlowTest.class, HiveStorageTest.class})
+public class TestHiveViewsSupport extends HiveTestBase {
+
+  @Test
+  public void selectStarFromView() throws Exception {
+    testBuilder()
+        .sqlQuery("SELECT * FROM hive.hiveview")
+        .unOrdered()
+        .baselineColumns("key", "value")
+        .baselineValues(1, " key_1")
+        .baselineValues(2, " key_2")
+        .baselineValues(3, " key_3")
+        .baselineValues(4, " key_4")
+        .baselineValues(5, " key_5")
+        .go();
+  }
+
+  @Test
+  public void useHiveAndSelectStarFromView() throws Exception {
+    test("USE hive");
+    testBuilder()
+        .sqlQuery("SELECT * FROM hiveview")
+        .unOrdered()
+        .baselineColumns("key", "value")
+        .baselineValues(1, " key_1")
+        .baselineValues(2, " key_2")
+        .baselineValues(3, " key_3")
+        .baselineValues(4, " key_4")
+        .baselineValues(5, " key_5")
+        .go();
+  }
+
+  @Test
+  public void joinViewAndTable() throws Exception {
+    testBuilder()
+        .sqlQuery("SELECT v.key AS key, t.`value` AS val " +
+            "FROM hive.kv t " +
+            "INNER JOIN hive.hiveview v " +
+            "ON v.key = t.key AND t.key=1")
+        .unOrdered()
+        .baselineColumns("key", "val")
+        .baselineValues(1, " key_1")
+        .go();
+  }
+
+  @Test
+  public void nativeParquetScanForView() throws Exception {
+    try {
+      
setSessionOption(ExecConstants.HIVE_OPTIMIZE_PARQUET_SCAN_WITH_NATIVE_READER, 
true);
+      setSessionOption(PlannerSettings.ENABLE_DECIMAL_DATA_TYPE_KEY, true);
+
+      String query = "select * from hive.kv_native_view where key > 1";
+
+      int actualRowCount = testSql(query);
+      assertEquals("Expected and actual row count should match", 2, 
actualRowCount);
+
+      testPlanMatchingPatterns(query,
+          new String[]{"HiveDrillNativeParquetScan", "numFiles=1"}, null);
+
+    } finally {
+      
resetSessionOption(ExecConstants.HIVE_OPTIMIZE_PARQUET_SCAN_WITH_NATIVE_READER);
+      resetSessionOption(PlannerSettings.ENABLE_DECIMAL_DATA_TYPE_KEY);
+    }
+
+  }
+
+  @Test
+  public void viewWithAllSupportedDataTypes() throws Exception {
+    testBuilder().sqlQuery("SELECT * FROM hive.readtest_view")
 
 Review comment:
   Will be fixed in scope of the task 
https://issues.apache.org/jira/browse/DRILL-6908. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to