Java Code Examples for org.apache.hadoop.hive.metastore.api.HiveObjectRef#setDbName()
The following examples show how to use
org.apache.hadoop.hive.metastore.api.HiveObjectRef#setDbName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AWSCatalogMetastoreClient.java From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 | 7 votes |
@Override public List<org.apache.hadoop.hive.metastore.api.Partition> listPartitionsWithAuthInfo(String database, String table, List<String> partVals, short maxParts, String user, List<String> groups) throws MetaException, TException, NoSuchObjectException { List<org.apache.hadoop.hive.metastore.api.Partition> partitions = listPartitions(database, table, partVals, maxParts); for (org.apache.hadoop.hive.metastore.api.Partition p : partitions) { HiveObjectRef obj = new HiveObjectRef(); obj.setObjectType(HiveObjectType.PARTITION); obj.setDbName(database); obj.setObjectName(table); obj.setPartValues(p.getValues()); org.apache.hadoop.hive.metastore.api.PrincipalPrivilegeSet set; try { set = get_privilege_set(obj, user, groups); } catch (MetaException e) { logger.info(String.format("No privileges found for user: %s, " + "groups: [%s]", user, LoggingHelper.concatCollectionToStringForLogging(groups, ","))); set = new org.apache.hadoop.hive.metastore.api.PrincipalPrivilegeSet(); } p.setPrivileges(set); } return partitions; }
Example 2
Source File: AWSCatalogMetastoreClient.java From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 | 6 votes |
@Override public org.apache.hadoop.hive.metastore.api.Partition getPartitionWithAuthInfo( String databaseName, String tableName, List<String> values, String userName, List<String> groupNames) throws MetaException, UnknownTableException, NoSuchObjectException, TException { // TODO move this into the service org.apache.hadoop.hive.metastore.api.Partition partition = getPartition(databaseName, tableName, values); org.apache.hadoop.hive.metastore.api.Table table = getTable(databaseName, tableName); if ("TRUE".equalsIgnoreCase(table.getParameters().get("PARTITION_LEVEL_PRIVILEGE"))) { String partName = Warehouse.makePartName(table.getPartitionKeys(), values); HiveObjectRef obj = new HiveObjectRef(); obj.setObjectType(HiveObjectType.PARTITION); obj.setDbName(databaseName); obj.setObjectName(tableName); obj.setPartValues(values); org.apache.hadoop.hive.metastore.api.PrincipalPrivilegeSet privilegeSet = this.get_privilege_set(obj, userName, groupNames); partition.setPrivileges(privilegeSet); } return partition; }
Example 3
Source File: AWSCatalogMetastoreClient.java From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 | 6 votes |
@Override public List<org.apache.hadoop.hive.metastore.api.Partition> listPartitionsWithAuthInfo(String database, String table, short maxParts, String user, List<String> groups) throws MetaException, TException, NoSuchObjectException { List<org.apache.hadoop.hive.metastore.api.Partition> partitions = listPartitions(database, table, maxParts); for (org.apache.hadoop.hive.metastore.api.Partition p : partitions) { HiveObjectRef obj = new HiveObjectRef(); obj.setObjectType(HiveObjectType.PARTITION); obj.setDbName(database); obj.setObjectName(table); obj.setPartValues(p.getValues()); org.apache.hadoop.hive.metastore.api.PrincipalPrivilegeSet set = this.get_privilege_set(obj, user, groups); p.setPrivileges(set); } return partitions; }
Example 4
Source File: AWSCatalogMetastoreClient.java From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 | 6 votes |
@Override public List<org.apache.hadoop.hive.metastore.api.Partition> listPartitionsWithAuthInfo(String database, String table, List<String> partVals, short maxParts, String user, List<String> groups) throws MetaException, TException, NoSuchObjectException { List<org.apache.hadoop.hive.metastore.api.Partition> partitions = listPartitions(database, table, partVals, maxParts); for (org.apache.hadoop.hive.metastore.api.Partition p : partitions) { HiveObjectRef obj = new HiveObjectRef(); obj.setObjectType(HiveObjectType.PARTITION); obj.setDbName(database); obj.setObjectName(table); obj.setPartValues(p.getValues()); org.apache.hadoop.hive.metastore.api.PrincipalPrivilegeSet set; try { set = get_privilege_set(obj, user, groups); } catch (MetaException e) { logger.info(String.format("No privileges found for user: %s, " + "groups: [%s]", user, LoggingHelper.concatCollectionToStringForLogging(groups, ","))); set = new org.apache.hadoop.hive.metastore.api.PrincipalPrivilegeSet(); } p.setPrivileges(set); } return partitions; }
Example 5
Source File: AWSCatalogMetastoreClient.java From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 | 6 votes |
@Override public org.apache.hadoop.hive.metastore.api.Partition getPartitionWithAuthInfo( String databaseName, String tableName, List<String> values, String userName, List<String> groupNames) throws MetaException, UnknownTableException, NoSuchObjectException, TException { // TODO move this into the service org.apache.hadoop.hive.metastore.api.Partition partition = getPartition(databaseName, tableName, values); org.apache.hadoop.hive.metastore.api.Table table = getTable(databaseName, tableName); if ("TRUE".equalsIgnoreCase(table.getParameters().get("PARTITION_LEVEL_PRIVILEGE"))) { String partName = Warehouse.makePartName(table.getPartitionKeys(), values); HiveObjectRef obj = new HiveObjectRef(); obj.setObjectType(HiveObjectType.PARTITION); obj.setDbName(databaseName); obj.setObjectName(tableName); obj.setPartValues(values); org.apache.hadoop.hive.metastore.api.PrincipalPrivilegeSet privilegeSet = this.get_privilege_set(obj, userName, groupNames); partition.setPrivileges(privilegeSet); } return partition; }
Example 6
Source File: AWSCatalogMetastoreClient.java From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 | 6 votes |
@Override public List<org.apache.hadoop.hive.metastore.api.Partition> listPartitionsWithAuthInfo(String database, String table, short maxParts, String user, List<String> groups) throws MetaException, TException, NoSuchObjectException { List<org.apache.hadoop.hive.metastore.api.Partition> partitions = listPartitions(database, table, maxParts); for (org.apache.hadoop.hive.metastore.api.Partition p : partitions) { HiveObjectRef obj = new HiveObjectRef(); obj.setObjectType(HiveObjectType.PARTITION); obj.setDbName(database); obj.setObjectName(table); obj.setPartValues(p.getValues()); org.apache.hadoop.hive.metastore.api.PrincipalPrivilegeSet set = this.get_privilege_set(obj, user, groups); p.setPrivileges(set); } return partitions; }
Example 7
Source File: FederatedHMSHandlerTest.java From waggle-dance with Apache License 2.0 | 6 votes |
@Test public void grant_revoke_privileges() throws TException { HiveObjectRef hiveObjectRef = new HiveObjectRef(); hiveObjectRef.setDbName(DB_P); HiveObjectPrivilege hiveObjectPrivilege = new HiveObjectPrivilege(); hiveObjectPrivilege.setHiveObject(hiveObjectRef); PrivilegeBag privileges = new PrivilegeBag(Collections.singletonList((hiveObjectPrivilege))); GrantRevokeType grantRevokeType = GrantRevokeType.GRANT; GrantRevokePrivilegeRequest request = new GrantRevokePrivilegeRequest(grantRevokeType, privileges); GrantRevokePrivilegeRequest inboundRequest = new GrantRevokePrivilegeRequest(); GrantRevokePrivilegeResponse expected = new GrantRevokePrivilegeResponse(); when(primaryMapping.transformInboundGrantRevokePrivilegesRequest(request)).thenReturn(inboundRequest); when(primaryClient.grant_revoke_privileges(inboundRequest)).thenReturn(expected); GrantRevokePrivilegeResponse response = handler.grant_revoke_privileges(request); assertThat(response, is(expected)); verify(primaryMapping).checkWritePermissions(DB_P); }
Example 8
Source File: HiveHelper.java From Hue-Ctrip-DI with MIT License | 5 votes |
public boolean hasPrivilegeToSetCleanAlert(String database, String table, String user) { HiveMetaStoreClient hiveClient = getHiveMetaStoreClient(); HiveObjectRef hiveObject = new HiveObjectRef(); hiveObject.setDbName(database); hiveObject.setObjectName(table); hiveObject.setObjectType(HiveObjectType.TABLE); List<HiveObjectPrivilege> privileges = new ArrayList<HiveObjectPrivilege>(); try { privileges = hiveClient.list_privileges(user, PrincipalType.USER, hiveObject); } catch (Exception e) { logger.error("Error to get privileges:", e); return false; } for (HiveObjectPrivilege privilege : privileges) { String privilegeName = privilege.getGrantInfo().getPrivilege(); if (privilegeName != null && ("all".equalsIgnoreCase(privilegeName) || "create".equalsIgnoreCase(privilegeName) || "ALTER" .equalsIgnoreCase(privilegeName))) { return true; } } return false; }
Example 9
Source File: TestObjects.java From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 | 5 votes |
public static HiveObjectRef getHiveObjectRef() { HiveObjectRef obj = new HiveObjectRef(); obj.setObjectType(HiveObjectType.TABLE); obj.setDbName("default"); obj.setObjectName("foo"); return obj; }
Example 10
Source File: FederatedHMSHandlerTest.java From waggle-dance with Apache License 2.0 | 5 votes |
@Test public void revoke_privileges() throws TException { HiveObjectRef hiveObjectRef = new HiveObjectRef(); hiveObjectRef.setDbName(DB_P); HiveObjectPrivilege hiveObjectPrivilege = new HiveObjectPrivilege(); hiveObjectPrivilege.setHiveObject(hiveObjectRef); PrivilegeBag privileges = new PrivilegeBag(Collections.singletonList((hiveObjectPrivilege))); PrivilegeBag inboundPrivileges = new PrivilegeBag(); when(primaryMapping.transformInboundPrivilegeBag(privileges)).thenReturn(inboundPrivileges); handler.revoke_privileges(privileges); verify(primaryMapping).checkWritePermissions(DB_P); verify(primaryClient).revoke_privileges(inboundPrivileges); }
Example 11
Source File: FederatedHMSHandlerTest.java From waggle-dance with Apache License 2.0 | 5 votes |
@Test public void grant_privileges() throws TException { HiveObjectRef hiveObjectRef = new HiveObjectRef(); hiveObjectRef.setDbName(DB_P); HiveObjectPrivilege hiveObjectPrivilege = new HiveObjectPrivilege(); hiveObjectPrivilege.setHiveObject(hiveObjectRef); PrivilegeBag privileges = new PrivilegeBag(Collections.singletonList((hiveObjectPrivilege))); PrivilegeBag inboundPrivileges = new PrivilegeBag(); when(primaryMapping.transformInboundPrivilegeBag(privileges)).thenReturn(inboundPrivileges); handler.grant_privileges(privileges); verify(primaryMapping).checkWritePermissions(DB_P); verify(primaryClient).grant_privileges(inboundPrivileges); }
Example 12
Source File: FederatedHMSHandlerTest.java From waggle-dance with Apache License 2.0 | 5 votes |
@Test public void list_privileges() throws TException { PrincipalType principalType = PrincipalType.findByValue(3); HiveObjectRef hiveObjectRef = new HiveObjectRef(); hiveObjectRef.setDbName(DB_P); HiveObjectRef inboundHiveObjectRef = new HiveObjectRef(); when(primaryMapping.transformInboundHiveObjectRef(hiveObjectRef)).thenReturn(inboundHiveObjectRef); handler.list_privileges("name", principalType, hiveObjectRef); verify(primaryClient).list_privileges("name", principalType, inboundHiveObjectRef); }
Example 13
Source File: FederatedHMSHandlerTest.java From waggle-dance with Apache License 2.0 | 5 votes |
@Test public void getPrivilegeSetDbNameIsNullShouldUsePrimary() throws TException { String userName = "user"; List<String> groupNames = Lists.newArrayList("group"); HiveObjectRef hiveObjectRef = new HiveObjectRef(); hiveObjectRef.setDbName(null); when(primaryMapping.transformInboundHiveObjectRef(hiveObjectRef)).thenReturn(hiveObjectRef); PrincipalPrivilegeSet principalPrivilegeSet = new PrincipalPrivilegeSet(); when(primaryClient.get_privilege_set(hiveObjectRef, userName, groupNames)).thenReturn(principalPrivilegeSet); PrincipalPrivilegeSet result = handler.get_privilege_set(hiveObjectRef, userName, groupNames); assertThat(result, is(principalPrivilegeSet)); verify(databaseMappingService, never()).databaseMapping(DB_P); }
Example 14
Source File: FederatedHMSHandlerTest.java From waggle-dance with Apache License 2.0 | 5 votes |
@Test public void getPrivilegeSet() throws TException { String userName = "user"; List<String> groupNames = Lists.newArrayList("group"); HiveObjectRef hiveObjectRef = new HiveObjectRef(); hiveObjectRef.setDbName(DB_P); when(databaseMappingService.databaseMapping(DB_P)).thenReturn(primaryMapping); when(primaryMapping.transformInboundHiveObjectRef(hiveObjectRef)).thenReturn(hiveObjectRef); PrincipalPrivilegeSet principalPrivilegeSet = new PrincipalPrivilegeSet(); when(primaryClient.get_privilege_set(hiveObjectRef, userName, groupNames)).thenReturn(principalPrivilegeSet); PrincipalPrivilegeSet result = handler.get_privilege_set(hiveObjectRef, userName, groupNames); assertThat(result, is(principalPrivilegeSet)); }
Example 15
Source File: DatabaseMappingImplTest.java From waggle-dance with Apache License 2.0 | 5 votes |
@Before public void setUp() { databaseMapping = new DatabaseMappingImpl(metastoreMapping, queryMapping); database = new Database(); database.setName(DB_NAME); partition = new Partition(); partition.setDbName(DB_NAME); partitions = Lists.newArrayList(partition); index = new Index(); index.setDbName(DB_NAME); hiveObjectRef = new HiveObjectRef(); hiveObjectRef.setDbName(DB_NAME); hiveObjectRef.setObjectType(HiveObjectType.DATABASE); hiveObjectRef.setObjectName(DB_NAME); hiveObjectPrivileges = new ArrayList<>(); HiveObjectPrivilege hiveObjectPrivilege = new HiveObjectPrivilege(); hiveObjectPrivilege.setHiveObject(hiveObjectRef); hiveObjectPrivileges.add(hiveObjectPrivilege); partitionSpec = new PartitionSpec(); partitionSpec.setDbName(DB_NAME); when(metastoreMapping.transformInboundDatabaseName(anyString())).thenReturn(IN_DB_NAME); when(metastoreMapping.transformOutboundDatabaseName(anyString())).thenReturn(OUT_DB_NAME); when(queryMapping.transformOutboundDatabaseName(metastoreMapping, VIEW_EXPANDED_TEXT)) .thenReturn(VIEW_EXPANDED_TEXT_TRANSFORMED); when(queryMapping.transformOutboundDatabaseName(metastoreMapping, VIEW_ORIGINAL_TEXT)) .thenReturn(VIEW_ORIGINAL_TEXT_TRANSFORMED); }
Example 16
Source File: DatabaseMappingImpl.java From waggle-dance with Apache License 2.0 | 5 votes |
@Override public HiveObjectRef transformOutboundHiveObjectRef(HiveObjectRef obj) { obj.setDbName(metaStoreMapping.transformOutboundDatabaseName(obj.getDbName())); if (obj.getObjectType() == HiveObjectType.DATABASE) { obj.setObjectName(metaStoreMapping.transformOutboundDatabaseName(obj.getObjectName())); } return obj; }
Example 17
Source File: DatabaseMappingImpl.java From waggle-dance with Apache License 2.0 | 5 votes |
@Override public HiveObjectRef transformInboundHiveObjectRef(HiveObjectRef obj) { obj.setDbName(metaStoreMapping.transformInboundDatabaseName(obj.getDbName())); if (obj.getObjectType() == HiveObjectType.DATABASE) { obj.setObjectName(metaStoreMapping.transformInboundDatabaseName(obj.getObjectName())); } return obj; }