use of org.apache.flink.table.catalog.exceptions.PartitionSpecInvalidException in project flink by apache.
the class HiveCatalog method alterPartitionStatistics.
@Override
public void alterPartitionStatistics(ObjectPath tablePath, CatalogPartitionSpec partitionSpec, CatalogTableStatistics partitionStatistics, boolean ignoreIfNotExists) throws PartitionNotExistException, CatalogException {
try {
Partition hivePartition = getHivePartition(tablePath, partitionSpec);
// Set table stats
if (statsChanged(partitionStatistics, hivePartition.getParameters())) {
updateStats(partitionStatistics, hivePartition.getParameters());
client.alter_partition(tablePath.getDatabaseName(), tablePath.getObjectName(), hivePartition);
}
} catch (TableNotExistException | PartitionSpecInvalidException e) {
throw new PartitionNotExistException(getName(), tablePath, partitionSpec, e);
} catch (TException e) {
throw new CatalogException(String.format("Failed to alter table stats of table %s 's partition %s", tablePath.getFullName(), String.valueOf(partitionSpec)), e);
}
}
use of org.apache.flink.table.catalog.exceptions.PartitionSpecInvalidException in project flink by apache.
the class HiveCatalog method dropPartition.
@Override
public void dropPartition(ObjectPath tablePath, CatalogPartitionSpec partitionSpec, boolean ignoreIfNotExists) throws PartitionNotExistException, CatalogException {
checkNotNull(tablePath, "Table path cannot be null");
checkNotNull(partitionSpec, "CatalogPartitionSpec cannot be null");
try {
Table hiveTable = getHiveTable(tablePath);
client.dropPartition(tablePath.getDatabaseName(), tablePath.getObjectName(), getOrderedFullPartitionValues(partitionSpec, getFieldNames(hiveTable.getPartitionKeys()), tablePath), true);
} catch (NoSuchObjectException e) {
if (!ignoreIfNotExists) {
throw new PartitionNotExistException(getName(), tablePath, partitionSpec, e);
}
} catch (MetaException | TableNotExistException | PartitionSpecInvalidException e) {
throw new PartitionNotExistException(getName(), tablePath, partitionSpec, e);
} catch (TException e) {
throw new CatalogException(String.format("Failed to drop partition %s of table %s", partitionSpec, tablePath));
}
}
use of org.apache.flink.table.catalog.exceptions.PartitionSpecInvalidException in project flink by apache.
the class HiveCatalog method alterPartition.
@Override
public void alterPartition(ObjectPath tablePath, CatalogPartitionSpec partitionSpec, CatalogPartition newPartition, boolean ignoreIfNotExists) throws PartitionNotExistException, CatalogException {
checkNotNull(tablePath, "Table path cannot be null");
checkNotNull(partitionSpec, "CatalogPartitionSpec cannot be null");
checkNotNull(newPartition, "New partition cannot be null");
// the target doesn't exist
try {
Table hiveTable = getHiveTable(tablePath);
boolean isHiveTable = isHiveTable(hiveTable.getParameters());
if (!isHiveTable) {
throw new CatalogException("Currently only supports partition for hive tables");
}
Partition hivePartition = getHivePartition(hiveTable, partitionSpec);
if (hivePartition == null) {
if (ignoreIfNotExists) {
return;
}
throw new PartitionNotExistException(getName(), tablePath, partitionSpec);
}
AlterTableOp op = HiveTableUtil.extractAlterTableOp(newPartition.getProperties());
if (op == null) {
throw new CatalogException(ALTER_TABLE_OP + " is missing for alter table operation");
}
alterTableViaProperties(op, null, null, hivePartition.getParameters(), newPartition.getProperties(), hivePartition.getSd());
client.alter_partition(tablePath.getDatabaseName(), tablePath.getObjectName(), hivePartition);
} catch (NoSuchObjectException e) {
if (!ignoreIfNotExists) {
throw new PartitionNotExistException(getName(), tablePath, partitionSpec, e);
}
} catch (InvalidOperationException | MetaException | TableNotExistException | PartitionSpecInvalidException e) {
throw new PartitionNotExistException(getName(), tablePath, partitionSpec, e);
} catch (TException e) {
throw new CatalogException(String.format("Failed to alter existing partition with new partition %s of table %s", partitionSpec, tablePath), e);
}
}
Aggregations