use of org.apache.flink.table.catalog.exceptions.PartitionNotExistException in project flink by apache.
the class GenericInMemoryCatalog method alterPartitionStatistics.
@Override
public void alterPartitionStatistics(ObjectPath tablePath, CatalogPartitionSpec partitionSpec, CatalogTableStatistics partitionStatistics, boolean ignoreIfNotExists) throws PartitionNotExistException {
checkNotNull(tablePath);
checkNotNull(partitionSpec);
checkNotNull(partitionStatistics);
if (partitionExists(tablePath, partitionSpec)) {
partitionStats.get(tablePath).put(partitionSpec, partitionStatistics.copy());
} else if (!ignoreIfNotExists) {
throw new PartitionNotExistException(getName(), tablePath, partitionSpec);
}
}
use of org.apache.flink.table.catalog.exceptions.PartitionNotExistException in project flink by apache.
the class GenericInMemoryCatalog method alterPartitionColumnStatistics.
@Override
public void alterPartitionColumnStatistics(ObjectPath tablePath, CatalogPartitionSpec partitionSpec, CatalogColumnStatistics columnStatistics, boolean ignoreIfNotExists) throws PartitionNotExistException {
checkNotNull(tablePath);
checkNotNull(partitionSpec);
checkNotNull(columnStatistics);
if (partitionExists(tablePath, partitionSpec)) {
partitionColumnStats.get(tablePath).put(partitionSpec, columnStatistics.copy());
} else if (!ignoreIfNotExists) {
throw new PartitionNotExistException(getName(), tablePath, partitionSpec);
}
}
use of org.apache.flink.table.catalog.exceptions.PartitionNotExistException in project flink by apache.
the class GenericInMemoryCatalog method dropPartition.
@Override
public void dropPartition(ObjectPath tablePath, CatalogPartitionSpec partitionSpec, boolean ignoreIfNotExists) throws PartitionNotExistException, CatalogException {
checkNotNull(tablePath);
checkNotNull(partitionSpec);
if (partitionExists(tablePath, partitionSpec)) {
partitions.get(tablePath).remove(partitionSpec);
partitionStats.get(tablePath).remove(partitionSpec);
partitionColumnStats.get(tablePath).remove(partitionSpec);
} else if (!ignoreIfNotExists) {
throw new PartitionNotExistException(getName(), tablePath, partitionSpec);
}
}
use of org.apache.flink.table.catalog.exceptions.PartitionNotExistException in project flink by apache.
the class PushPartitionIntoTableSourceScanRule method getPartitionStats.
private Optional<TableStats> getPartitionStats(Catalog catalog, ObjectPath tablePath, Map<String, String> partition) {
try {
CatalogPartitionSpec spec = new CatalogPartitionSpec(partition);
CatalogTableStatistics partitionStat = catalog.getPartitionStatistics(tablePath, spec);
CatalogColumnStatistics partitionColStat = catalog.getPartitionColumnStatistics(tablePath, spec);
TableStats stats = CatalogTableStatisticsConverter.convertToTableStats(partitionStat, partitionColStat);
return Optional.of(stats);
} catch (PartitionNotExistException e) {
return Optional.empty();
}
}
use of org.apache.flink.table.catalog.exceptions.PartitionNotExistException 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