org.apache.hadoop.hive.metastore.api.InvalidOperationException Java Examples
The following examples show how to use
org.apache.hadoop.hive.metastore.api.InvalidOperationException.
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: AWSCatalogMetastoreClientTest.java From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 | 6 votes |
@Test(expected=InvalidOperationException.class) public void testRenamePartitionForInvalidSD() throws Exception { String dbName = testDB.getName(); Table externalTable = getTestTable(); externalTable.setTableType(TableType.EXTERNAL_TABLE.name()); StorageDescriptor sd = HiveToCatalogConverter.convertStorageDescriptor(testPartition.getSd()); Partition oldPartition = new Partition() .withDatabaseName(dbName).withTableName(externalTable.getName()) .withValues(Lists.newArrayList("oldval")).withStorageDescriptor(null); Partition newPartition = new Partition() .withDatabaseName(dbName).withTableName(externalTable.getName()) .withValues(Lists.newArrayList("newval")).withStorageDescriptor(sd); when(glueClient.getDatabase(any(GetDatabaseRequest.class))) .thenReturn(new GetDatabaseResult().withDatabase(HiveToCatalogConverter.convertDatabase(testDB))); when(glueClient.getTable(any(GetTableRequest.class))) .thenReturn(new GetTableResult().withTable(externalTable)); when(glueClient.getPartition(any(GetPartitionRequest.class))) .thenReturn(new GetPartitionResult().withPartition(oldPartition)); metastoreClient.renamePartition(dbName, externalTable.getName(), oldPartition.getValues(), CatalogToHiveConverter.convertPartition(newPartition)); }
Example #2
Source File: AWSCatalogMetastoreClientTest.java From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 | 6 votes |
@Test(expected=InvalidOperationException.class) public void testRenamePartitionForUnknownPartition() throws Exception { String dbName = testDB.getName(); Table externalTable = getTestTable(); externalTable.setTableType(TableType.EXTERNAL_TABLE.name()); StorageDescriptor sd = HiveToCatalogConverter.convertStorageDescriptor(testPartition.getSd()); Partition oldPartition = new Partition() .withDatabaseName(dbName).withTableName(externalTable.getName()) .withValues(Lists.newArrayList("oldval")).withStorageDescriptor(sd); Partition newPartition = new Partition() .withDatabaseName(dbName).withTableName(externalTable.getName()) .withValues(Lists.newArrayList("newval")).withStorageDescriptor(sd); when(glueClient.getDatabase(any(GetDatabaseRequest.class))) .thenReturn(new GetDatabaseResult().withDatabase(HiveToCatalogConverter.convertDatabase(testDB))); when(glueClient.getTable(any(GetTableRequest.class))) .thenReturn(new GetTableResult().withTable(externalTable)); doThrow(EntityNotFoundException.class).when(glueClient).getPartition(any(GetPartitionRequest.class)); metastoreClient.renamePartition(dbName, externalTable.getName(), oldPartition.getValues(), CatalogToHiveConverter.convertPartition(newPartition)); }
Example #3
Source File: AWSCatalogMetastoreClientTest.java From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 | 6 votes |
@Test(expected=InvalidOperationException.class) public void testRenamePartitionForUnknownTable() throws Exception { String dbName = testDB.getName(); Table externalTable = getTestTable(); externalTable.setTableType(TableType.EXTERNAL_TABLE.name()); StorageDescriptor sd = HiveToCatalogConverter.convertStorageDescriptor(testPartition.getSd()); Partition oldPartition = new Partition() .withDatabaseName(dbName).withTableName(externalTable.getName()) .withValues(Lists.newArrayList("oldval")).withStorageDescriptor(sd); Partition newPartition = new Partition() .withDatabaseName(dbName).withTableName(externalTable.getName()) .withValues(Lists.newArrayList("newval")).withStorageDescriptor(sd); when(glueClient.getDatabase(any(GetDatabaseRequest.class))) .thenReturn(new GetDatabaseResult().withDatabase(HiveToCatalogConverter.convertDatabase(testDB))); doThrow(EntityNotFoundException.class).when(glueClient).getTable(any(GetTableRequest.class)); when(glueClient.getPartition(any(GetPartitionRequest.class))) .thenReturn(new GetPartitionResult().withPartition(oldPartition)); metastoreClient.renamePartition(dbName, externalTable.getName(), oldPartition.getValues(), CatalogToHiveConverter.convertPartition(newPartition)); }
Example #4
Source File: HiveShimV210.java From flink with Apache License 2.0 | 6 votes |
@Override public void alterPartition(IMetaStoreClient client, String databaseName, String tableName, Partition partition) throws InvalidOperationException, MetaException, TException { String errorMsg = "Failed to alter partition for table %s in database %s"; try { Method method = client.getClass().getMethod("alter_partition", String.class, String.class, Partition.class, EnvironmentContext.class); method.invoke(client, databaseName, tableName, partition, null); } catch (InvocationTargetException ite) { Throwable targetEx = ite.getTargetException(); if (targetEx instanceof TException) { throw (TException) targetEx; } else { throw new CatalogException(String.format(errorMsg, tableName, databaseName), targetEx); } } catch (NoSuchMethodException | IllegalAccessException e) { throw new CatalogException(String.format(errorMsg, tableName, databaseName), e); } }
Example #5
Source File: HiveShimV100.java From flink with Apache License 2.0 | 6 votes |
@Override public void alterPartition(IMetaStoreClient client, String databaseName, String tableName, Partition partition) throws InvalidOperationException, MetaException, TException { String errorMsg = "Failed to alter partition for table %s in database %s"; try { Method method = client.getClass().getMethod("alter_partition", String.class, String.class, Partition.class); method.invoke(client, databaseName, tableName, partition); } catch (InvocationTargetException ite) { Throwable targetEx = ite.getTargetException(); if (targetEx instanceof TException) { throw (TException) targetEx; } else { throw new CatalogException(String.format(errorMsg, tableName, databaseName), targetEx); } } catch (NoSuchMethodException | IllegalAccessException e) { throw new CatalogException(String.format(errorMsg, tableName, databaseName), e); } }
Example #6
Source File: AWSCatalogMetastoreClient.java From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 | 6 votes |
private void verifyDestinationLocation(FileSystem srcFs, FileSystem destFs, Path srcPath, Path destPath, org.apache.hadoop.hive.metastore.api.Table tbl, org.apache.hadoop.hive.metastore.api.Partition newPartition) throws InvalidOperationException { String oldPartLoc = srcPath.toString(); String newPartLoc = destPath.toString(); // check that src and dest are on the same file system if (!FileUtils.equalsFileSystem(srcFs, destFs)) { throw new InvalidOperationException("table new location " + destPath + " is on a different file system than the old location " + srcPath + ". This operation is not supported"); } try { srcFs.exists(srcPath); // check that src exists and also checks if (newPartLoc.compareTo(oldPartLoc) != 0 && destFs.exists(destPath)) { throw new InvalidOperationException("New location for this partition " + tbl.getDbName() + "." + tbl.getTableName() + "." + newPartition.getValues() + " already exists : " + destPath); } } catch (IOException e) { throw new InvalidOperationException("Unable to access new location " + destPath + " for partition " + tbl.getDbName() + "." + tbl.getTableName() + " " + newPartition.getValues()); } }
Example #7
Source File: MetastoreAuthzBinding.java From incubator-sentry with Apache License 2.0 | 6 votes |
private void authorizeCreateTable(PreCreateTableEvent context) throws InvalidOperationException, MetaException { HierarcyBuilder inputBuilder = new HierarcyBuilder(); inputBuilder.addDbToOutput(getAuthServer(), context.getTable().getDbName()); HierarcyBuilder outputBuilder = new HierarcyBuilder(); outputBuilder.addDbToOutput(getAuthServer(), context.getTable().getDbName()); if (!StringUtils.isEmpty(context.getTable().getSd().getLocation())) { String uriPath; try { uriPath = PathUtils.parseDFSURI(warehouseDir, getSdLocation(context.getTable().getSd())); } catch(URISyntaxException e) { throw new MetaException(e.getMessage()); } inputBuilder.addUriToOutput(getAuthServer(), uriPath, warehouseDir); } authorizeMetastoreAccess(HiveOperation.CREATETABLE, inputBuilder.build(), outputBuilder.build()); }
Example #8
Source File: AWSCatalogMetastoreClient.java From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 | 6 votes |
private void verifyDestinationLocation(FileSystem srcFs, FileSystem destFs, Path srcPath, Path destPath, org.apache.hadoop.hive.metastore.api.Table tbl, org.apache.hadoop.hive.metastore.api.Partition newPartition) throws InvalidOperationException { String oldPartLoc = srcPath.toString(); String newPartLoc = destPath.toString(); // check that src and dest are on the same file system if (!FileUtils.equalsFileSystem(srcFs, destFs)) { throw new InvalidOperationException("table new location " + destPath + " is on a different file system than the old location " + srcPath + ". This operation is not supported"); } try { srcFs.exists(srcPath); // check that src exists and also checks if (newPartLoc.compareTo(oldPartLoc) != 0 && destFs.exists(destPath)) { throw new InvalidOperationException("New location for this partition " + tbl.getDbName() + "." + tbl.getTableName() + "." + newPartition.getValues() + " already exists : " + destPath); } } catch (IOException e) { throw new InvalidOperationException("Unable to access new location " + destPath + " for partition " + tbl.getDbName() + "." + tbl.getTableName() + " " + newPartition.getValues()); } }
Example #9
Source File: AWSCatalogMetastoreClient.java From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 | 5 votes |
private void renamePartitionInCatalog(String databaseName, String tableName, List<String> partitionValues, org.apache.hadoop.hive.metastore.api.Partition newPartition) throws InvalidOperationException, MetaException, TException { try { glueClient.updatePartition( new UpdatePartitionRequest() .withDatabaseName(databaseName) .withTableName(tableName) .withPartitionValueList(partitionValues) .withPartitionInput(GlueInputConverter.convertToPartitionInput(newPartition))); } catch (AmazonServiceException e) { throw CatalogToHiveConverter.wrapInHiveException(e); } }
Example #10
Source File: FederatedHMSHandler.java From waggle-dance with Apache License 2.0 | 5 votes |
@Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public List<Table> get_table_objects_by_name(String dbname, List<String> tbl_names) throws MetaException, InvalidOperationException, UnknownDBException, TException { DatabaseMapping mapping = databaseMappingService.databaseMapping(dbname); List<Table> tables = mapping .getClient() .get_table_objects_by_name(mapping.transformInboundDatabaseName(dbname), tbl_names); List<Table> outboundTables = new ArrayList<>(tables.size()); for (Table table : tables) { outboundTables.add(mapping.transformOutboundTable(table)); } return outboundTables; }
Example #11
Source File: HiveShimV1.java From flink with Apache License 2.0 | 5 votes |
@Override public void alterTable(IMetaStoreClient client, String databaseName, String tableName, Table table) throws InvalidOperationException, MetaException, TException { // For Hive-1.2.1, we need to tell HMS not to update stats. Otherwise, the stats we put in the table // parameters can be overridden. The extra config we add here will be removed by HMS after it's used. table.getParameters().put(StatsSetupConst.DO_NOT_UPDATE_STATS, "true"); client.alter_table(databaseName, tableName, table); }
Example #12
Source File: HiveShimV120.java From flink with Apache License 2.0 | 5 votes |
@Override public void alterTable(IMetaStoreClient client, String databaseName, String tableName, Table table) throws InvalidOperationException, MetaException, TException { // For Hive-1.2.x, we need to tell HMS not to update stats. Otherwise, the stats we put in the table // parameters can be overridden. The extra config we add here will be removed by HMS after it's used. // Don't use StatsSetupConst.DO_NOT_UPDATE_STATS because it wasn't defined in Hive 1.1.x. table.getParameters().put("DO_NOT_UPDATE_STATS", "true"); client.alter_table(databaseName, tableName, table); }
Example #13
Source File: MetastoreAuthzBinding.java From incubator-sentry with Apache License 2.0 | 5 votes |
private void authorizeAlterTable(PreAlterTableEvent context) throws InvalidOperationException, MetaException { /* * There are multiple alter table options and it's tricky to figure which is * attempted here. Currently all alter table needs full level privilege * except the for setting location which also needs a privile on URI. Hence * we set initially set the operation to ALTERTABLE_ADDCOLS. If the client * has specified the location, then change to ALTERTABLE_LOCATION */ HiveOperation operation = HiveOperation.ALTERTABLE_ADDCOLS; HierarcyBuilder inputBuilder = new HierarcyBuilder(); inputBuilder.addTableToOutput(getAuthServer(), context.getOldTable() .getDbName(), context.getOldTable().getTableName()); HierarcyBuilder outputBuilder = new HierarcyBuilder(); outputBuilder.addTableToOutput(getAuthServer(), context.getOldTable() .getDbName(), context.getOldTable().getTableName()); // if the operation requires location change, then add URI privilege check String oldLocationUri; String newLocationUri; try { oldLocationUri = PathUtils.parseDFSURI(warehouseDir, getSdLocation(context.getOldTable().getSd())); newLocationUri = PathUtils.parseDFSURI(warehouseDir, getSdLocation(context.getNewTable().getSd())); } catch (URISyntaxException e) { throw new MetaException(e.getMessage()); } if (oldLocationUri.compareTo(newLocationUri) != 0) { outputBuilder.addUriToOutput(getAuthServer(), newLocationUri, warehouseDir); operation = HiveOperation.ALTERTABLE_LOCATION; } authorizeMetastoreAccess( operation, inputBuilder.build(), outputBuilder.build()); }
Example #14
Source File: AWSCatalogMetastoreClient.java From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 | 5 votes |
private Path getDestinationPathForRename(String dbName, org.apache.hadoop.hive.metastore.api.Table tbl, org.apache.hadoop.hive.metastore.api.Partition newPartition) throws InvalidOperationException, MetaException, TException { try { Path destPath = new Path(hiveShims.getDefaultTablePath(getDatabase(dbName), tbl.getTableName(), wh), Warehouse.makePartName(tbl.getPartitionKeys(), newPartition.getValues())); return constructRenamedPath(destPath, new Path(newPartition.getSd().getLocation())); } catch (NoSuchObjectException e) { throw new InvalidOperationException( "Unable to change partition or table. Database " + dbName + " does not exist" + " Check metastore logs for detailed stack." + e.getMessage()); } }
Example #15
Source File: AWSCatalogMetastoreClient.java From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 | 5 votes |
@Override public List<org.apache.hadoop.hive.metastore.api.Table> getTableObjectsByName(String dbName, List<String> tableNames) throws MetaException, InvalidOperationException, UnknownDBException, TException { List<org.apache.hadoop.hive.metastore.api.Table> hiveTables = Lists.newArrayList(); for(String tableName : tableNames) { hiveTables.add(getTable(dbName, tableName)); } return hiveTables; }
Example #16
Source File: MetastoreAuthzBindingV2.java From incubator-sentry with Apache License 2.0 | 5 votes |
protected void authorizeDropPartition(PreDropPartitionEvent context) throws InvalidOperationException, MetaException { authorizeMetastoreAccess( HiveOperation.ALTERTABLE_DROPPARTS, new HierarcyBuilder().addTableToOutput(getAuthServer(), context.getTable().getDbName(), context.getTable().getTableName()).build(), new HierarcyBuilder().addTableToOutput(getAuthServer(), context.getTable().getDbName(), context.getTable().getTableName()).build()); }
Example #17
Source File: AWSCatalogMetastoreClient.java From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 | 5 votes |
@Override public void alter_table( String dbName, String tblName, org.apache.hadoop.hive.metastore.api.Table table ) throws InvalidOperationException, MetaException, TException { alter_table(dbName, tblName, table, false); }
Example #18
Source File: AWSCatalogMetastoreClient.java From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 | 5 votes |
@Override public void alter_table_with_environmentContext( String dbName, String tblName, org.apache.hadoop.hive.metastore.api.Table table, EnvironmentContext environmentContext ) throws InvalidOperationException, MetaException, TException { glueMetastoreClientDelegate.alterTable(dbName, tblName, table, environmentContext); }
Example #19
Source File: FederatedHMSHandler.java From waggle-dance with Apache License 2.0 | 5 votes |
@Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public List<String> get_table_names_by_filter(String dbname, String filter, short max_tables) throws MetaException, InvalidOperationException, UnknownDBException, TException { DatabaseMapping mapping = databaseMappingService.databaseMapping(dbname); return mapping .getClient() .get_table_names_by_filter(mapping.transformInboundDatabaseName(dbname), filter, max_tables); }
Example #20
Source File: FederatedHMSHandler.java From waggle-dance with Apache License 2.0 | 5 votes |
@Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public void alter_table(String dbname, String tbl_name, Table new_tbl) throws InvalidOperationException, MetaException, TException { DatabaseMapping mapping = checkWritePermissions(dbname); mapping.checkWritePermissions(new_tbl.getDbName()); mapping .getClient() .alter_table(mapping.transformInboundDatabaseName(dbname), tbl_name, mapping.transformInboundTable(new_tbl)); }
Example #21
Source File: FederatedHMSHandler.java From waggle-dance with Apache License 2.0 | 5 votes |
@Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public void alter_table_with_environment_context( String dbname, String tbl_name, Table new_tbl, EnvironmentContext environment_context) throws InvalidOperationException, MetaException, TException { DatabaseMapping mapping = checkWritePermissions(dbname); mapping.checkWritePermissions(new_tbl.getDbName()); mapping .getClient() .alter_table_with_environment_context(mapping.transformInboundDatabaseName(dbname), tbl_name, mapping.transformInboundTable(new_tbl), environment_context); }
Example #22
Source File: FederatedHMSHandler.java From waggle-dance with Apache License 2.0 | 5 votes |
@Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public void alter_partition(String db_name, String tbl_name, Partition new_part) throws InvalidOperationException, MetaException, TException { DatabaseMapping mapping = checkWritePermissions(db_name); mapping.checkWritePermissions(new_part.getDbName()); mapping .getClient() .alter_partition(mapping.transformInboundDatabaseName(db_name), tbl_name, mapping.transformInboundPartition(new_part)); }
Example #23
Source File: FederatedHMSHandler.java From waggle-dance with Apache License 2.0 | 5 votes |
@Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public void alter_partitions(String db_name, String tbl_name, List<Partition> new_parts) throws InvalidOperationException, MetaException, TException { DatabaseMapping mapping = checkWritePermissions(db_name); for (Partition newPart : new_parts) { mapping.checkWritePermissions(newPart.getDbName()); } mapping .getClient() .alter_partitions(mapping.transformInboundDatabaseName(db_name), tbl_name, mapping.transformInboundPartitions(new_parts)); }
Example #24
Source File: FederatedHMSHandler.java From waggle-dance with Apache License 2.0 | 5 votes |
@Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public void alter_partition_with_environment_context( String db_name, String tbl_name, Partition new_part, EnvironmentContext environment_context) throws InvalidOperationException, MetaException, TException { DatabaseMapping mapping = checkWritePermissions(db_name); mapping.checkWritePermissions(new_part.getDbName()); mapping .getClient() .alter_partition_with_environment_context(mapping.transformInboundDatabaseName(db_name), tbl_name, mapping.transformInboundPartition(new_part), environment_context); }
Example #25
Source File: FederatedHMSHandler.java From waggle-dance with Apache License 2.0 | 5 votes |
@Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public void rename_partition(String db_name, String tbl_name, List<String> part_vals, Partition new_part) throws InvalidOperationException, MetaException, TException { DatabaseMapping mapping = checkWritePermissions(db_name); mapping.checkWritePermissions(new_part.getDbName()); mapping.getClient().rename_partition(mapping.transformInboundDatabaseName(db_name), tbl_name, part_vals, new_part); }
Example #26
Source File: FederatedHMSHandler.java From waggle-dance with Apache License 2.0 | 5 votes |
@Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public void alter_index(String dbname, String base_tbl_name, String idx_name, Index new_idx) throws InvalidOperationException, MetaException, TException { DatabaseMapping mapping = checkWritePermissions(dbname); mapping.checkWritePermissions(new_idx.getDbName()); mapping .getClient() .alter_index(mapping.transformInboundDatabaseName(dbname), base_tbl_name, idx_name, mapping.transformInboundIndex(new_idx)); }
Example #27
Source File: FederatedHMSHandler.java From waggle-dance with Apache License 2.0 | 5 votes |
@Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public void alter_function(String dbName, String funcName, Function newFunc) throws InvalidOperationException, MetaException, TException { DatabaseMapping mapping = checkWritePermissions(dbName); mapping.checkWritePermissions(newFunc.getDbName()); mapping .getClient() .alter_function(mapping.transformInboundDatabaseName(dbName), funcName, mapping.transformInboundFunction(newFunc)); }
Example #28
Source File: FederatedHMSHandler.java From waggle-dance with Apache License 2.0 | 5 votes |
@Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public void alter_partitions_with_environment_context( String db_name, String tbl_name, List<Partition> new_parts, EnvironmentContext environment_context) throws InvalidOperationException, MetaException, TException { DatabaseMapping mapping = checkWritePermissions(db_name); mapping .getClient() .alter_partitions_with_environment_context(mapping.transformInboundDatabaseName(db_name), tbl_name, new_parts, environment_context); }
Example #29
Source File: FederatedHMSHandler.java From waggle-dance with Apache License 2.0 | 5 votes |
@Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public void alter_table_with_cascade(String dbname, String tbl_name, Table new_tbl, boolean cascade) throws InvalidOperationException, MetaException, TException { DatabaseMapping mapping = checkWritePermissions(dbname); mapping .getClient() .alter_table_with_cascade(mapping.transformInboundDatabaseName(dbname), tbl_name, new_tbl, cascade); }
Example #30
Source File: FederatedHMSHandler.java From waggle-dance with Apache License 2.0 | 5 votes |
@Override @Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME) public GetTablesResult get_table_objects_by_name_req(GetTablesRequest req) throws MetaException, InvalidOperationException, UnknownDBException, TException { DatabaseMapping mapping = databaseMappingService.databaseMapping(req.getDbName()); GetTablesResult result = mapping .getClient() .get_table_objects_by_name_req(mapping.transformInboundGetTablesRequest(req)); return mapping.transformOutboundGetTablesResult(result); }