org.apache.flink.table.catalog.exceptions.PartitionAlreadyExistsException Java Examples

The following examples show how to use org.apache.flink.table.catalog.exceptions.PartitionAlreadyExistsException. 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: GenericInMemoryCatalog.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public void createPartition(ObjectPath tablePath, CatalogPartitionSpec partitionSpec, CatalogPartition partition, boolean ignoreIfExists)
		throws TableNotExistException, TableNotPartitionedException, PartitionSpecInvalidException, PartitionAlreadyExistsException, CatalogException {
	checkNotNull(tablePath);
	checkNotNull(partitionSpec);
	checkNotNull(partition);

	ensureTableExists(tablePath);
	ensurePartitionedTable(tablePath);
	ensureFullPartitionSpec(tablePath, partitionSpec);

	if (partitionExists(tablePath, partitionSpec)) {
		if (!ignoreIfExists) {
			throw new PartitionAlreadyExistsException(getName(), tablePath, partitionSpec);
		}
	}

	partitions.get(tablePath).put(partitionSpec, partition.copy());
}
 
Example #2
Source File: GenericInMemoryCatalog.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public void createPartition(ObjectPath tablePath, CatalogPartitionSpec partitionSpec, CatalogPartition partition, boolean ignoreIfExists)
		throws TableNotExistException, TableNotPartitionedException, PartitionSpecInvalidException, PartitionAlreadyExistsException, CatalogException {
	checkNotNull(tablePath);
	checkNotNull(partitionSpec);
	checkNotNull(partition);

	ensureTableExists(tablePath);
	ensurePartitionedTable(tablePath);
	ensureFullPartitionSpec(tablePath, partitionSpec);

	if (partitionExists(tablePath, partitionSpec)) {
		if (!ignoreIfExists) {
			throw new PartitionAlreadyExistsException(getName(), tablePath, partitionSpec);
		}
	}

	partitions.get(tablePath).put(partitionSpec, partition.copy());
}
 
Example #3
Source File: CatalogTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testCreatePartition_PartitionAlreadyExistsException() throws Exception {
	catalog.createDatabase(db1, createDb(), false);
	catalog.createTable(path1, createPartitionedTable(), false);
	CatalogPartition partition = createPartition();
	catalog.createPartition(path1, createPartitionSpec(), partition, false);

	CatalogPartitionSpec partitionSpec = createPartitionSpec();

	exception.expect(PartitionAlreadyExistsException.class);
	exception.expectMessage(
		String.format("Partition %s of table %s in catalog %s already exists.",
			partitionSpec, path1.getFullName(), TEST_CATALOG_NAME));
	catalog.createPartition(path1, partitionSpec, createPartition(), false);
}
 
Example #4
Source File: CatalogTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testCreatePartition_PartitionAlreadyExistsException() throws Exception {
	catalog.createDatabase(db1, createDb(), false);
	catalog.createTable(path1, createPartitionedTable(), false);
	CatalogPartition partition = createPartition();
	catalog.createPartition(path1, createPartitionSpec(), partition, false);

	CatalogPartitionSpec partitionSpec = createPartitionSpec();

	exception.expect(PartitionAlreadyExistsException.class);
	exception.expectMessage(
		String.format("Partition %s of table %s in catalog %s already exists.",
			partitionSpec, path1.getFullName(), TEST_CATALOG_NAME));
	catalog.createPartition(path1, partitionSpec, createPartition(), false);
}
 
Example #5
Source File: PulsarCatalog.java    From pulsar-flink with Apache License 2.0 4 votes vote down vote up
@Override
public void createPartition(ObjectPath tablePath, CatalogPartitionSpec partitionSpec, CatalogPartition partition, boolean ignoreIfExists) throws TableNotExistException, TableNotPartitionedException, PartitionSpecInvalidException, PartitionAlreadyExistsException, CatalogException {
    throw new UnsupportedOperationException();
}
 
Example #6
Source File: AbstractReadOnlyCatalog.java    From bahir-flink with Apache License 2.0 4 votes vote down vote up
@Override
public void createPartition(ObjectPath tablePath, CatalogPartitionSpec partitionSpec, CatalogPartition partition, boolean ignoreIfExists) throws TableNotExistException, TableNotPartitionedException, PartitionSpecInvalidException, PartitionAlreadyExistsException, CatalogException {
    throw UNSUPPORTED_ERR;
}
 
Example #7
Source File: AbstractJdbcCatalog.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public void createPartition(ObjectPath tablePath, CatalogPartitionSpec partitionSpec, CatalogPartition partition, boolean ignoreIfExists) throws TableNotExistException, TableNotPartitionedException, PartitionSpecInvalidException, PartitionAlreadyExistsException, CatalogException {
	throw new UnsupportedOperationException();
}
 
Example #8
Source File: Catalog.java    From flink with Apache License 2.0 2 votes vote down vote up
/**
 * Create a partition.
 *
 * @param tablePath path of the table.
 * @param partitionSpec partition spec of the partition
 * @param partition the partition to add.
 * @param ignoreIfExists flag to specify behavior if a table with the given name already exists:
 *                       if set to false, it throws a TableAlreadyExistException,
 *                       if set to true, nothing happens.
 *
 * @throws TableNotExistException thrown if the target table does not exist
 * @throws TableNotPartitionedException thrown if the target table is not partitioned
 * @throws PartitionSpecInvalidException thrown if the given partition spec is invalid
 * @throws PartitionAlreadyExistsException thrown if the target partition already exists
 * @throws CatalogException in case of any runtime exception
 */
void createPartition(ObjectPath tablePath, CatalogPartitionSpec partitionSpec, CatalogPartition partition, boolean ignoreIfExists)
	throws TableNotExistException, TableNotPartitionedException, PartitionSpecInvalidException, PartitionAlreadyExistsException, CatalogException;
 
Example #9
Source File: Catalog.java    From flink with Apache License 2.0 2 votes vote down vote up
/**
 * Create a partition.
 *
 * @param tablePath path of the table.
 * @param partitionSpec partition spec of the partition
 * @param partition the partition to add.
 * @param ignoreIfExists flag to specify behavior if a table with the given name already exists:
 *                       if set to false, it throws a TableAlreadyExistException,
 *                       if set to true, nothing happens.
 *
 * @throws TableNotExistException thrown if the target table does not exist
 * @throws TableNotPartitionedException thrown if the target table is not partitioned
 * @throws PartitionSpecInvalidException thrown if the given partition spec is invalid
 * @throws PartitionAlreadyExistsException thrown if the target partition already exists
 * @throws CatalogException in case of any runtime exception
 */
void createPartition(ObjectPath tablePath, CatalogPartitionSpec partitionSpec, CatalogPartition partition, boolean ignoreIfExists)
	throws TableNotExistException, TableNotPartitionedException, PartitionSpecInvalidException, PartitionAlreadyExistsException, CatalogException;