org.apache.hadoop.hive.metastore.api.InvalidInputException Java Examples

The following examples show how to use org.apache.hadoop.hive.metastore.api.InvalidInputException. 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: MetacatHMSHandler.java    From metacat with Apache License 2.0 6 votes vote down vote up
private List<Partition> dropPartitionsCoreNoTxn(
        final RawStore ms, final Table tbl, final List<List<String>> partsValues)
        throws MetaException, NoSuchObjectException, InvalidObjectException, InvalidInputException {
    final List<Partition> deletedPartitions = new ArrayList<Partition>();
    Partition part = null;
    final String dbName = tbl.getDbName();
    final String tblName = tbl.getTableName();

    for (List<String> partValues : partsValues) {
        part = ms.getPartition(dbName, tblName, partValues);
        if (part == null) {
            throw new NoSuchObjectException("Partition doesn't exist. "
                    + partValues);
        }
        if (!ms.dropPartition(dbName, tblName, partValues)) {
            throw new MetaException("Unable to drop partition");
        }
        deletedPartitions.add(part);
    }
    return deletedPartitions;
}
 
Example #2
Source File: BatchDeletePartitionsHelperTest.java    From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 6 votes vote down vote up
@Test
public void testDeletePartitionsThrowsInvalidInputException() throws Exception {
  Exception e = new com.amazonaws.services.glue.model.InvalidInputException("foo");
  mockBatchDeleteThrowsException(e);

  List<String> values1 = Lists.newArrayList("val1");
  List<String> values2 = Lists.newArrayList("val2");
  List<Partition> partitions = Lists.newArrayList(
        TestObjects.getTestPartition(NAMESPACE_NAME, TABLE_NAME, values1),
        TestObjects.getTestPartition(NAMESPACE_NAME, TABLE_NAME, values2));
  batchDeletePartitionsHelper = new BatchDeletePartitionsHelper(client, NAMESPACE_NAME, TABLE_NAME, null, partitions);

  batchDeletePartitionsHelper.deletePartitions();
  assertTrue(batchDeletePartitionsHelper.getPartitionsDeleted().isEmpty());
  assertThat(batchDeletePartitionsHelper.getFirstTException(), is(instanceOf(InvalidObjectException.class)));
}
 
Example #3
Source File: BatchDeletePartitionsHelperTest.java    From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 6 votes vote down vote up
@Test
public void testDeletePartitionsWithFailures() throws Exception {
  List<String> values1 = Lists.newArrayList("val1");
  List<String> values2 = Lists.newArrayList("val2");
  Partition partition1 = TestObjects.getTestPartition(NAMESPACE_NAME, TABLE_NAME, values1);
  Partition partition2 = TestObjects.getTestPartition(NAMESPACE_NAME, TABLE_NAME, values2);
  List<Partition> partitions = Lists.newArrayList(partition1, partition2);

  PartitionError error1 = getPartitionError(values1, new EntityNotFoundException("foo error msg"));
  PartitionError error2 = getPartitionError(values2, new InvalidInputException("foo error msg2"));
  mockBatchDeleteWithFailures(Lists.newArrayList(error1, error2));

  batchDeletePartitionsHelper = new BatchDeletePartitionsHelper(client, NAMESPACE_NAME, TABLE_NAME, null, partitions)
        .deletePartitions();

  assertEquals(0, batchDeletePartitionsHelper.getPartitionsDeleted().size());
  assertTrue(batchDeletePartitionsHelper.getFirstTException() instanceof NoSuchObjectException);
}
 
Example #4
Source File: FederatedHMSHandler.java    From waggle-dance with Apache License 2.0 6 votes vote down vote up
@Override
@Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME)
public List<Partition> exchange_partitions(
    Map<String, String> partitionSpecs,
    String source_db,
    String source_table_name,
    String dest_db,
    String dest_table_name)
    throws MetaException, NoSuchObjectException, InvalidObjectException, InvalidInputException, TException {
  DatabaseMapping mapping = checkWritePermissions(source_db);
  mapping.checkWritePermissions(dest_db);
  List<Partition> result = mapping
      .getClient()
      .exchange_partitions(partitionSpecs, mapping.transformInboundDatabaseName(source_db), source_table_name,
          mapping.transformInboundDatabaseName(dest_db), dest_table_name);
  return mapping.transformOutboundPartitions(result);
}
 
Example #5
Source File: FederatedHMSHandler.java    From waggle-dance with Apache License 2.0 6 votes vote down vote up
@Override
@Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME)
public Partition exchange_partition(
    Map<String, String> partitionSpecs,
    String source_db,
    String source_table_name,
    String dest_db,
    String dest_table_name)
    throws MetaException, NoSuchObjectException, InvalidObjectException, InvalidInputException, TException {
  DatabaseMapping mapping = checkWritePermissions(source_db);
  mapping.checkWritePermissions(dest_db);
  Partition result = mapping
      .getClient()
      .exchange_partition(partitionSpecs, mapping.transformInboundDatabaseName(source_db), source_table_name,
          mapping.transformInboundDatabaseName(dest_db), dest_table_name);
  return mapping.transformOutboundPartition(result);
}
 
Example #6
Source File: FederatedHMSHandler.java    From waggle-dance with Apache License 2.0 5 votes vote down vote up
@Override
@Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME)
public boolean update_table_column_statistics(ColumnStatistics stats_obj)
    throws NoSuchObjectException, InvalidObjectException, MetaException, InvalidInputException, TException {
  DatabaseMapping mapping = checkWritePermissions(stats_obj.getStatsDesc().getDbName());
  return mapping.getClient().update_table_column_statistics(mapping.transformInboundColumnStatistics(stats_obj));
}
 
Example #7
Source File: FederatedHMSHandler.java    From waggle-dance with Apache License 2.0 5 votes vote down vote up
@Override
@Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME)
public boolean delete_table_column_statistics(String db_name, String tbl_name, String col_name)
    throws NoSuchObjectException, MetaException, InvalidObjectException, InvalidInputException, TException {
  DatabaseMapping mapping = checkWritePermissions(db_name);
  return mapping
      .getClient()
      .delete_table_column_statistics(mapping.transformInboundDatabaseName(db_name), tbl_name, col_name);
}
 
Example #8
Source File: FederatedHMSHandler.java    From waggle-dance with Apache License 2.0 5 votes vote down vote up
@Override
@Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME)
public boolean delete_partition_column_statistics(String db_name, String tbl_name, String part_name, String col_name)
    throws NoSuchObjectException, MetaException, InvalidObjectException, InvalidInputException, TException {
  DatabaseMapping mapping = checkWritePermissions(db_name);
  return mapping
      .getClient()
      .delete_partition_column_statistics(mapping.transformInboundDatabaseName(db_name), tbl_name, part_name,
          col_name);
}
 
Example #9
Source File: FederatedHMSHandler.java    From waggle-dance with Apache License 2.0 5 votes vote down vote up
@Override
@Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME)
public boolean set_aggr_stats_for(SetPartitionsStatsRequest request)
    throws NoSuchObjectException, InvalidObjectException, MetaException, InvalidInputException, TException {
  if (!request.getColStats().isEmpty()) {
    DatabaseMapping mapping = databaseMappingService
        .databaseMapping(request.getColStats().get(0).getStatsDesc().getDbName());
    for (ColumnStatistics stats : request.getColStats()) {
      mapping.checkWritePermissions(stats.getStatsDesc().getDbName());
    }
    return mapping.getClient().set_aggr_stats_for(mapping.transformInboundSetPartitionStatsRequest(request));
  }
  return false;
}
 
Example #10
Source File: FederatedHMSHandler.java    From waggle-dance with Apache License 2.0 5 votes vote down vote up
@Override
@Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME)
public ColumnStatistics get_partition_column_statistics(
    String db_name,
    String tbl_name,
    String part_name,
    String col_name)
    throws NoSuchObjectException, MetaException, InvalidInputException, InvalidObjectException, TException {
  DatabaseMapping mapping = databaseMappingService.databaseMapping(db_name);
  ColumnStatistics result = mapping
      .getClient()
      .get_partition_column_statistics(mapping.transformInboundDatabaseName(db_name), tbl_name, part_name, col_name);
  return mapping.transformOutboundColumnStatistics(result);
}
 
Example #11
Source File: FederatedHMSHandler.java    From waggle-dance with Apache License 2.0 5 votes vote down vote up
@Override
@Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME)
public ColumnStatistics get_table_column_statistics(String db_name, String tbl_name, String col_name)
    throws NoSuchObjectException, MetaException, InvalidInputException, InvalidObjectException, TException {
  DatabaseMapping mapping = databaseMappingService.databaseMapping(db_name);
  ColumnStatistics result = mapping
      .getClient()
      .get_table_column_statistics(mapping.transformInboundDatabaseName(db_name), tbl_name, col_name);
  return mapping.transformOutboundColumnStatistics(result);
}
 
Example #12
Source File: FederatedHMSHandler.java    From waggle-dance with Apache License 2.0 5 votes vote down vote up
@Override
@Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME)
public boolean update_partition_column_statistics(ColumnStatistics stats_obj)
    throws NoSuchObjectException, InvalidObjectException, MetaException, InvalidInputException, TException {
  DatabaseMapping mapping = checkWritePermissions(stats_obj.getStatsDesc().getDbName());
  return mapping.getClient().update_partition_column_statistics(mapping.transformInboundColumnStatistics(stats_obj));
}
 
Example #13
Source File: CatalogThriftHiveMetastore.java    From metacat with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void alter_database(final String dbname, final Database db) throws TException {
    requestWrapper("update_database", new Object[]{db}, () -> {
        if (dbname == null || db == null) {
            throw new InvalidInputException("Invalid database request");
        }
        v1.updateDatabase(catalogName, normalizeIdentifier(dbname),
            DatabaseCreateRequestDto.builder().metadata(db.getParameters()).uri(db.getLocationUri()).build());
        return null;
    });
}
 
Example #14
Source File: HiveMetastoreClientWrapper.java    From flink with Apache License 2.0 4 votes vote down vote up
public boolean updatePartitionColumnStatistics(ColumnStatistics columnStatistics)
		throws NoSuchObjectException, InvalidObjectException, MetaException, TException, InvalidInputException {
	return client.updatePartitionColumnStatistics(columnStatistics);
}
 
Example #15
Source File: HiveMetastoreClientWrapper.java    From flink with Apache License 2.0 4 votes vote down vote up
public void dropFunction(String databaseName, String functionName)
		throws MetaException, NoSuchObjectException, InvalidObjectException, InvalidInputException, TException {
	client.dropFunction(databaseName, functionName);
}
 
Example #16
Source File: HiveMetastoreClientWrapper.java    From flink with Apache License 2.0 4 votes vote down vote up
public boolean updateTableColumnStatistics(ColumnStatistics columnStatistics)
		throws NoSuchObjectException, InvalidObjectException, MetaException, TException, InvalidInputException {
	return client.updateTableColumnStatistics(columnStatistics);
}
 
Example #17
Source File: SubmarineMetaStore.java    From submarine with Apache License 2.0 4 votes vote down vote up
public boolean dropTable(String dbName, String tableName)
    throws MetaException, InvalidObjectException, NoSuchObjectException, InvalidInputException {
  boolean result = rs.dropTable(dbName, tableName);
  return result;
}
 
Example #18
Source File: MetacatHMSHandler.java    From metacat with Apache License 2.0 4 votes vote down vote up
private boolean addDropPartitionsCore(
        final RawStore ms, final String databaseName, final String tableName, final List<Partition> addParts,
        final List<List<String>> dropParts, final boolean ifNotExists, final EnvironmentContext envContext)
        throws MetaException, InvalidObjectException, NoSuchObjectException, AlreadyExistsException,
        IOException, InvalidInputException, TException {
    logInfo("add_drop_partitions : db=" + databaseName + " tbl=" + tableName);
    boolean success = false;
    Table tbl = null;
    // Ensures that the list doesn't have dups, and keeps track of directories we have created.
    final Map<PartValEqWrapper, Boolean> addedPartitions = new HashMap<PartValEqWrapper, Boolean>();
    final List<Partition> existingParts = new ArrayList<Partition>();
    List<Partition> result = null;
    try {
        ms.openTransaction();
        tbl = get_table(databaseName, tableName);
        if (tbl == null) {
            throw new NoSuchObjectException("Unable to add partitions because "
                    + "database or table " + databaseName + "." + tableName + " does not exist");
        }
        // Drop the parts first
        dropPartitionsCoreNoTxn(ms, tbl, dropParts);

        // Now add the parts
        result = addPartitionsCoreNoTxn(ms, tbl, addParts, ifNotExists, addedPartitions, existingParts);

        if (!result.isEmpty() && !ms.addPartitions(databaseName, tableName, result)) {
            throw new MetaException("Unable to add partitions");
        }
        success = ms.commitTransaction();
    } finally {
        if (!success) {
            ms.rollbackTransaction();
            // Clean up the result of adding partitions
            for (Map.Entry<PartValEqWrapper, Boolean> e : addedPartitions.entrySet()) {
                if (e.getValue()) {
                    getWh().deleteDir(new Path(e.getKey().partition.getSd().getLocation()), true);
                    // we just created this directory - it's not a case of pre-creation, so we nuke
                }
            }
        }
    }
    return success;
}
 
Example #19
Source File: HiveMetastoreClientWrapper.java    From flink with Apache License 2.0 4 votes vote down vote up
public boolean updatePartitionColumnStatistics(ColumnStatistics columnStatistics)
		throws NoSuchObjectException, InvalidObjectException, MetaException, TException, InvalidInputException {
	return client.updatePartitionColumnStatistics(columnStatistics);
}
 
Example #20
Source File: HiveMetastoreClientWrapper.java    From flink with Apache License 2.0 4 votes vote down vote up
public boolean updateTableColumnStatistics(ColumnStatistics columnStatistics)
		throws NoSuchObjectException, InvalidObjectException, MetaException, TException, InvalidInputException {
	return client.updateTableColumnStatistics(columnStatistics);
}
 
Example #21
Source File: HiveMetastoreClientWrapper.java    From flink with Apache License 2.0 4 votes vote down vote up
public void dropFunction(String databaseName, String functionName)
		throws MetaException, NoSuchObjectException, InvalidObjectException, InvalidInputException, TException {
	client.dropFunction(databaseName, functionName);
}
 
Example #22
Source File: SubmarineMetaStore.java    From submarine with Apache License 2.0 4 votes vote down vote up
public boolean dropPartition(String dbName, String tableName, List<String> partVals)
    throws MetaException, NoSuchObjectException, InvalidObjectException,
    InvalidInputException {
  boolean result = rs.dropPartition(dbName, tableName, partVals);
  return result;
}