[
https://issues.apache.org/jira/browse/HIVE-26247?focusedWorklogId=810246&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-810246
]
ASF GitHub Bot logged work on HIVE-26247:
-----------------------------------------
Author: ASF GitHub Bot
Created on: 20/Sep/22 04:41
Start Date: 20/Sep/22 04:41
Worklog Time Spent: 10m
Work Description: zhangbutao commented on code in PR #3545:
URL: https://github.com/apache/hive/pull/3545#discussion_r974878654
##########
ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/metastore/filtercontext/DataConnectorFilterContext.java:
##########
@@ -0,0 +1,76 @@
+/*
+ * 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.security.authorization.plugin.metastore.filtercontext;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import
org.apache.hadoop.hive.ql.security.authorization.plugin.HiveOperationType;
+import
org.apache.hadoop.hive.ql.security.authorization.plugin.HivePrivilegeObject;
+import
org.apache.hadoop.hive.ql.security.authorization.plugin.metastore.HiveMetaStoreAuthorizableEvent;
+import
org.apache.hadoop.hive.ql.security.authorization.plugin.metastore.HiveMetaStoreAuthzInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DataConnectorFilterContext extends HiveMetaStoreAuthorizableEvent
{
+
+ private static final Logger LOG =
LoggerFactory.getLogger(DataConnectorFilterContext.class);
+
+ List<String> connectors = null;
+
+ public DataConnectorFilterContext(List<String> connectors) {
+ super(null);
+ this.connectors = connectors;
+ getAuthzContext();
+ }
+
+ @Override
+ public HiveMetaStoreAuthzInfo getAuthzContext() {
+ HiveMetaStoreAuthzInfo ret =
+ new HiveMetaStoreAuthzInfo(preEventContext,
HiveOperationType.QUERY, getInputHObjs(), getOutputHObjs(), null);
+ return ret;
+ }
+
+ private List<HivePrivilegeObject> getInputHObjs() {
+ LOG.debug("==> DataConnectorFilterContext.getOutputHObjs()");
+
+ List<HivePrivilegeObject> ret = new ArrayList<>();
+ for (String connector : connectors) {
+ HivePrivilegeObject.HivePrivilegeObjectType type =
HivePrivilegeObject.HivePrivilegeObjectType.DATACONNECTOR;
+ HivePrivilegeObject.HivePrivObjectActionType objectActionType =
+ HivePrivilegeObject.HivePrivObjectActionType.OTHER;
+ HivePrivilegeObject hivePrivilegeObject =
+ new HivePrivilegeObject(type, null, connector, null, null,
objectActionType, null, null);
Review Comment:
Good suggestion. But we lack of HMS api for getting all dataconnector
objects and we can only all dataconnectors names by
`HMSHandler::get_dataconnectors()`, so we can not set owner's name and
owner-type in here.
https://github.com/apache/hive/blob/master/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java#L2033-L2034
If we want do this, i think we can define a new HtMS api or define a new api
in RawStore to get all dataconnector objects, like get all tables objects:
https://github.com/apache/hive/blob/master/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/RawStore.java#L609-L610
I think we can do this in following task. wdyt? @saihemanth-cloudera Thank
you.
Issue Time Tracking
-------------------
Worklog Id: (was: 810246)
Time Spent: 1h (was: 50m)
> Filter out results 'show connectors' on HMS server-side
> -------------------------------------------------------
>
> Key: HIVE-26247
> URL: https://issues.apache.org/jira/browse/HIVE-26247
> Project: Hive
> Issue Type: Sub-task
> Affects Versions: 4.0.0-alpha-1, 4.0.0-alpha-2
> Reporter: zhangbutao
> Assignee: zhangbutao
> Priority: Major
> Labels: pull-request-available
> Time Spent: 1h
> Remaining Estimate: 0h
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)