nrg4878 commented on a change in pull request #1960:
URL: https://github.com/apache/hive/pull/1960#discussion_r610056943
##########
File path: ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
##########
@@ -13707,14 +13709,27 @@ ASTNode analyzeCreateTable(
/** Adds entities for create table/create view. */
private void addDbAndTabToOutputs(String[] qualifiedTabName, TableType type,
- boolean isTemporary, Map<String, String> tblProps) throws
SemanticException {
+ boolean isTemporary, Map<String, String> tblProps, StorageFormat
storageFormat) throws SemanticException {
Database database = getDatabase(qualifiedTabName[0]);
outputs.add(new WriteEntity(database, WriteEntity.WriteType.DDL_SHARED));
Table t = new Table(qualifiedTabName[0], qualifiedTabName[1]);
t.setParameters(tblProps);
t.setTableType(type);
t.setTemporary(isTemporary);
+ HiveStorageHandler storageHandler = null;
+ if(storageFormat.getStorageHandler() != null) {
+ try {
+ storageHandler = (HiveStorageHandler) ReflectionUtils.newInstance(
+ conf.getClassByName(storageFormat.getStorageHandler()),
SessionState.get().getConf());
+ } catch (ClassNotFoundException ex) {
+ System.out.println("Class not found. Storage handler will be set to
null: " + ex);
Review comment:
Please remove System.out.println and use a log handler instead. or throw
an exception if we should not continue.
##########
File path:
ql/src/java/org/apache/hadoop/hive/ql/security/authorization/command/CommandAuthorizerV2.java
##########
@@ -185,6 +191,33 @@ private static void addHivePrivObject(Entity privObject,
Map<String, List<String
tableName2Cols.get(Table.getCompleteName(table.getDbName(),
table.getTableName()));
hivePrivObject = new HivePrivilegeObject(privObjType, table.getDbName(),
table.getTableName(),
null, columns, actionType, null, null, table.getOwner(),
table.getOwnerType());
+ if(table.getStorageHandler() != null){
+ //TODO: add hive privilege object for storage based handlers for
create and alter table commands.
+ if(hiveOpType == HiveOperationType.CREATETABLE ||
+ hiveOpType == HiveOperationType.ALTERTABLE_PROPERTIES ||
+ hiveOpType == HiveOperationType.CREATETABLE_AS_SELECT){
+ String storageuri = null;
+ Map<String, String> tableProperties = new HashMap<>();
+ Configuration conf = new Configuration();
+ tableProperties.putAll(table.getSd().getSerdeInfo().getParameters());
+ tableProperties.putAll(table.getParameters());
+ try {
+ if(table.getStorageHandler() instanceof
HiveStorageAuthorizationHandler){
+ HiveStorageAuthorizationHandler authorizationHandler =
(HiveStorageAuthorizationHandler) ReflectionUtils.newInstance(
+
conf.getClassByName(table.getStorageHandler().getClass().getName()),
SessionState.get().getConf());
+ storageuri =
authorizationHandler.getURIForAuth(tableProperties).toString();
+ }else{
+ //Custom storage handler that has not implemented the
HiveStorageAuthorizationHandler
+ storageuri =
table.getStorageHandler().getClass().getName()+"://"+
+
HiveCustomStorageHandlerUtils.getTablePropsForCustomStorageHandler(tableProperties);
+ }
+ }catch(Exception ex){
+ ex.printStackTrace();
Review comment:
can you either log this exception to the log file if this is concerning
to the user or ignore it if it not an issue, with a comment instead of
printStackTrace() ? This goes to STDOUT and not to the server log.
##########
File path:
ql/src/java/org/apache/hadoop/hive/ql/metadata/HiveStorageAuthorizationHandler.java
##########
@@ -0,0 +1,49 @@
+/*
+ * 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.hadoop.hive.ql.metadata;
+
+import org.apache.hadoop.hive.common.classification.InterfaceAudience;
+import org.apache.hadoop.hive.common.classification.InterfaceStability;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Map;
+
+/**
+ * HiveStorageAuthorizationHandler defines a pluggable interface for
+ * authorization of storage based tables in Hive. A Storage authorization
+ * handler consists of a bundle of the following:
+ *
+ *<ul>
+ *<li>getURI
+ *</ul>
+ *
+ * Storage authorization handler classes are plugged in using the STORED BY
'classname'
+ * clause in CREATE TABLE.
+ */
[email protected]
[email protected]
+public interface HiveStorageAuthorizationHandler{
Review comment:
Thats ok then. Thank you
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]