use of org.apache.flink.table.catalog.exceptions.PartitionAlreadyExistsException in project flink by apache.
the class HiveCatalog method createPartition.
@Override
public void createPartition(ObjectPath tablePath, CatalogPartitionSpec partitionSpec, CatalogPartition partition, boolean ignoreIfExists) throws TableNotExistException, TableNotPartitionedException, PartitionSpecInvalidException, PartitionAlreadyExistsException, CatalogException {
checkNotNull(tablePath, "Table path cannot be null");
checkNotNull(partitionSpec, "CatalogPartitionSpec cannot be null");
checkNotNull(partition, "Partition cannot be null");
Table hiveTable = getHiveTable(tablePath);
ensurePartitionedTable(tablePath, hiveTable);
// partition doesn't have connector property, so check the table
boolean isHiveTable = isHiveTable(hiveTable.getParameters());
if (!isHiveTable) {
throw new CatalogException("Currently only supports partition for hive tables");
}
try {
client.add_partition(instantiateHivePartition(hiveTable, partitionSpec, partition));
} catch (AlreadyExistsException e) {
if (!ignoreIfExists) {
throw new PartitionAlreadyExistsException(getName(), tablePath, partitionSpec);
}
} catch (TException e) {
throw new CatalogException(String.format("Failed to create partition %s of table %s", partitionSpec, tablePath), e);
}
}
Aggregations