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_r242152276
 
 

 ##########
 File path: 
contrib/storage-hive/core/src/main/java/org/apache/drill/exec/store/hive/schema/DrillHiveViewTable.java
 ##########
 @@ -17,26 +17,90 @@
  */
 package org.apache.drill.exec.store.hive.schema;
 
-import org.apache.calcite.schema.Schema.TableType;
+import java.util.Collection;
+import java.util.List;
+import java.util.stream.Stream;
 
-import org.apache.drill.exec.planner.logical.DrillViewInfoProvider;
+import org.apache.calcite.plan.RelOptTable;
+import org.apache.calcite.rel.RelNode;
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.schema.SchemaPlus;
+import org.apache.calcite.sql.type.SqlTypeFactoryImpl;
+import org.apache.drill.exec.dotdrill.View;
+import org.apache.drill.exec.planner.logical.DrillViewTable;
+import org.apache.drill.exec.planner.sql.SchemaUtilites;
+import org.apache.drill.exec.planner.types.DrillRelDataTypeSystem;
+import org.apache.drill.exec.planner.types.HiveToRelDataTypeConverter;
+import org.apache.drill.exec.store.SchemaConfig;
 import org.apache.drill.exec.store.hive.HiveReadEntry;
-import org.apache.drill.exec.store.hive.HiveStoragePlugin;
+import org.apache.drill.exec.store.hive.HiveTableWithColumnCache;
+import org.apache.drill.shaded.guava.com.google.common.collect.ImmutableList;
 
-public class DrillHiveViewTable extends DrillHiveTable implements 
DrillViewInfoProvider {
+import static java.util.stream.Collectors.toList;
 
-  public DrillHiveViewTable(String storageEngineName, HiveStoragePlugin 
plugin, String userName,
-      HiveReadEntry readEntry) {
-    super(storageEngineName, plugin, userName, readEntry);
+/**
+ * DrillViewTable which may be created from Hive view metadata and will work
+ * similar to views defined in Drill.
+ */
+public class DrillHiveViewTable extends DrillViewTable {
+
+  private static final HiveToRelDataTypeConverter DATA_TYPE_CONVERTER = new 
HiveToRelDataTypeConverter(
+      new 
SqlTypeFactoryImpl(DrillRelDataTypeSystem.DRILL_REL_DATATYPE_SYSTEM));
+
+  public DrillHiveViewTable(HiveReadEntry entry, List<String> schemaPath,
+                            SchemaConfig schemaConfig,
+                            String user) {
+    super(createView(schemaPath, entry.getTable()), user, 
schemaConfig.getViewExpansionContext());
   }
 
+  /**
+   * Because tables used by hive views, defined without name
+   * of storage plugin, we're making sure that storage plugin
+   * name will be taken into account for the special case,
+   * when hive storage based authorization is used, and user
+   * can query view, but doesn't have rights to  access underlying
+   * table.
+   *
+   * @param context - to rel conversion context
+   * @param rowType - data type of requested columns
+   * @param workspaceSchemaPath - path to view in drill, for example: ["hive"]
+   * @param tokenSchemaTree - schema created for impersonated user
+   * @return
 
 Review comment:
   fixed

----------------------------------------------------------------
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