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

The following examples show how to use org.apache.flink.table.catalog.exceptions.PartitionNotExistException. 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 alterPartition(ObjectPath tablePath, CatalogPartitionSpec partitionSpec, CatalogPartition newPartition, boolean ignoreIfNotExists)
		throws PartitionNotExistException, CatalogException {
	checkNotNull(tablePath);
	checkNotNull(partitionSpec);
	checkNotNull(newPartition);

	if (partitionExists(tablePath, partitionSpec)) {
		CatalogPartition existingPartition = partitions.get(tablePath).get(partitionSpec);

		if (existingPartition.getClass() != newPartition.getClass()) {
			throw new CatalogException(
				String.format("Partition types don't match. Existing partition is '%s' and new partition is '%s'.",
					existingPartition.getClass().getName(), newPartition.getClass().getName())
			);
		}

		partitions.get(tablePath).put(partitionSpec, newPartition.copy());
	} else if (!ignoreIfNotExists) {
		throw new PartitionNotExistException(getName(), tablePath, partitionSpec);
	}
}
 
Example #2
Source File: CatalogTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetPartition_PartitionSpecInvalid_sizeNotEqual() throws Exception {
	catalog.createDatabase(db1, createDb(), false);
	CatalogTable table = createPartitionedTable();
	catalog.createTable(path1, table, false);

	CatalogPartitionSpec partitionSpec = new CatalogPartitionSpec(
		new HashMap<String, String>() {{
			put("second", "bob");
		}}
	);
	exception.expect(PartitionNotExistException.class);
	exception.expectMessage(
		String.format("Partition %s of table %s in catalog %s does not exist.",
			partitionSpec, path1.getFullName(), TEST_CATALOG_NAME));
	catalog.getPartition(path1, partitionSpec);
}
 
Example #3
Source File: GenericInMemoryCatalog.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public void alterPartition(ObjectPath tablePath, CatalogPartitionSpec partitionSpec, CatalogPartition newPartition, boolean ignoreIfNotExists)
		throws PartitionNotExistException, CatalogException {
	checkNotNull(tablePath);
	checkNotNull(partitionSpec);
	checkNotNull(newPartition);

	if (partitionExists(tablePath, partitionSpec)) {
		CatalogPartition existingPartition = partitions.get(tablePath).get(partitionSpec);

		if (existingPartition.getClass() != newPartition.getClass()) {
			throw new CatalogException(
				String.format("Partition types don't match. Existing partition is '%s' and new partition is '%s'.",
					existingPartition.getClass().getName(), newPartition.getClass().getName())
			);
		}

		partitions.get(tablePath).put(partitionSpec, newPartition.copy());
	} else if (!ignoreIfNotExists) {
		throw new PartitionNotExistException(getName(), tablePath, partitionSpec);
	}
}
 
Example #4
Source File: CatalogTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetPartition_PartitionSpecInvalid_sizeNotEqual() throws Exception {
	catalog.createDatabase(db1, createDb(), false);
	CatalogTable table = createPartitionedTable();
	catalog.createTable(path1, table, false);

	CatalogPartitionSpec partitionSpec = new CatalogPartitionSpec(
		new HashMap<String, String>() {{
			put("second", "bob");
		}}
	);
	exception.expect(PartitionNotExistException.class);
	exception.expectMessage(
		String.format("Partition %s of table %s in catalog %s does not exist.",
			partitionSpec, path1.getFullName(), TEST_CATALOG_NAME));
	catalog.getPartition(path1, partitionSpec);
}
 
Example #5
Source File: CatalogTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetPartition_TableNotPartitioned() throws Exception {
	catalog.createDatabase(db1, createDb(), false);
	catalog.createTable(path1, createTable(), false);

	CatalogPartitionSpec partitionSpec = createPartitionSpec();
	exception.expect(PartitionNotExistException.class);
	exception.expectMessage(
		String.format("Partition %s of table %s in catalog %s does not exist.", partitionSpec,
			path1.getFullName(), TEST_CATALOG_NAME));
	catalog.getPartition(path1, partitionSpec);
}
 
Example #6
Source File: GenericInMemoryCatalog.java    From flink with Apache License 2.0 5 votes vote down vote up
@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);
	}
}
 
Example #7
Source File: CatalogTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetPartition_PartitionNotExist() throws Exception {
	catalog.createDatabase(db1, createDb(), false);
	catalog.createTable(path1, createPartitionedTable(), false);

	CatalogPartitionSpec partitionSpec = createPartitionSpec();
	exception.expect(PartitionNotExistException.class);
	exception.expectMessage(
		String.format("Partition %s of table %s in catalog %s does not exist.",
			partitionSpec, path1.getFullName(), TEST_CATALOG_NAME));
	catalog.getPartition(path1, partitionSpec);
}
 
Example #8
Source File: CatalogTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetPartition_PartitionSpecInvalid_invalidPartitionSpec() throws Exception {
	catalog.createDatabase(db1, createDb(), false);
	CatalogTable table = createPartitionedTable();
	catalog.createTable(path1, table, false);

	CatalogPartitionSpec partitionSpec = createInvalidPartitionSpecSubset();
	exception.expect(PartitionNotExistException.class);
	exception.expectMessage(
		String.format("Partition %s of table %s in catalog %s does not exist.",
			partitionSpec, path1.getFullName(), TEST_CATALOG_NAME));
	catalog.getPartition(path1, partitionSpec);
}
 
Example #9
Source File: CatalogTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetPartition_TableNotPartitioned() throws Exception {
	catalog.createDatabase(db1, createDb(), false);
	catalog.createTable(path1, createTable(), false);

	CatalogPartitionSpec partitionSpec = createPartitionSpec();
	exception.expect(PartitionNotExistException.class);
	exception.expectMessage(
		String.format("Partition %s of table %s in catalog %s does not exist.", partitionSpec,
			path1.getFullName(), TEST_CATALOG_NAME));
	catalog.getPartition(path1, partitionSpec);
}
 
Example #10
Source File: GenericInMemoryCatalog.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public CatalogPartition getPartition(ObjectPath tablePath, CatalogPartitionSpec partitionSpec)
		throws PartitionNotExistException, CatalogException {
	checkNotNull(tablePath);
	checkNotNull(partitionSpec);

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

	return partitions.get(tablePath).get(partitionSpec).copy();
}
 
Example #11
Source File: GenericInMemoryCatalog.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public CatalogPartition getPartition(ObjectPath tablePath, CatalogPartitionSpec partitionSpec)
		throws PartitionNotExistException, CatalogException {
	checkNotNull(tablePath);
	checkNotNull(partitionSpec);

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

	return partitions.get(tablePath).get(partitionSpec).copy();
}
 
Example #12
Source File: CatalogTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetPartition_PartitionSpecInvalid_invalidPartitionSpec() throws Exception {
	catalog.createDatabase(db1, createDb(), false);
	CatalogTable table = createPartitionedTable();
	catalog.createTable(path1, table, false);

	CatalogPartitionSpec partitionSpec = createInvalidPartitionSpecSubset();
	exception.expect(PartitionNotExistException.class);
	exception.expectMessage(
		String.format("Partition %s of table %s in catalog %s does not exist.",
			partitionSpec, path1.getFullName(), TEST_CATALOG_NAME));
	catalog.getPartition(path1, partitionSpec);
}
 
Example #13
Source File: CatalogTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetPartition_PartitionNotExist() throws Exception {
	catalog.createDatabase(db1, createDb(), false);
	catalog.createTable(path1, createPartitionedTable(), false);

	CatalogPartitionSpec partitionSpec = createPartitionSpec();
	exception.expect(PartitionNotExistException.class);
	exception.expectMessage(
		String.format("Partition %s of table %s in catalog %s does not exist.",
			partitionSpec, path1.getFullName(), TEST_CATALOG_NAME));
	catalog.getPartition(path1, partitionSpec);
}
 
Example #14
Source File: GenericInMemoryCatalog.java    From flink with Apache License 2.0 5 votes vote down vote up
@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);
	}
}
 
Example #15
Source File: GenericInMemoryCatalog.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public CatalogColumnStatistics getPartitionColumnStatistics(ObjectPath tablePath, CatalogPartitionSpec partitionSpec)
		throws PartitionNotExistException {
	checkNotNull(tablePath);
	checkNotNull(partitionSpec);

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

	CatalogColumnStatistics result = partitionColumnStats.get(tablePath).get(partitionSpec);
	return result != null ? result.copy() : CatalogColumnStatistics.UNKNOWN;
}
 
Example #16
Source File: GenericInMemoryCatalog.java    From flink with Apache License 2.0 5 votes vote down vote up
@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);
	}
}
 
Example #17
Source File: GenericInMemoryCatalog.java    From flink with Apache License 2.0 5 votes vote down vote up
@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);
	}
}
 
Example #18
Source File: CatalogManager.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Retrieves a partition with a fully qualified table path and partition spec.
 * If the path is not yet fully qualified use{@link #qualifyIdentifier(UnresolvedIdentifier)} first.
 *
 * @param tableIdentifier full path of the table to retrieve
 * @param partitionSpec full partition spec
 * @return partition in the table.
 */
public Optional<CatalogPartition> getPartition(ObjectIdentifier tableIdentifier, CatalogPartitionSpec partitionSpec) {
	Catalog catalog = catalogs.get(tableIdentifier.getCatalogName());
	if (catalog != null) {
		try {
			return Optional.of(catalog.getPartition(tableIdentifier.toObjectPath(), partitionSpec));
		} catch (PartitionNotExistException ignored) {
		}
	}
	return Optional.empty();
}
 
Example #19
Source File: GenericInMemoryCatalog.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public CatalogTableStatistics getPartitionStatistics(ObjectPath tablePath, CatalogPartitionSpec partitionSpec)
		throws PartitionNotExistException {
	checkNotNull(tablePath);
	checkNotNull(partitionSpec);

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

	CatalogTableStatistics result = partitionStats.get(tablePath).get(partitionSpec);
	return result != null ? result.copy() : CatalogTableStatistics.UNKNOWN;
}
 
Example #20
Source File: GenericInMemoryCatalog.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public CatalogColumnStatistics getPartitionColumnStatistics(ObjectPath tablePath, CatalogPartitionSpec partitionSpec)
		throws PartitionNotExistException {
	checkNotNull(tablePath);
	checkNotNull(partitionSpec);

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

	CatalogColumnStatistics result = partitionColumnStats.get(tablePath).get(partitionSpec);
	return result != null ? result.copy() : CatalogColumnStatistics.UNKNOWN;
}
 
Example #21
Source File: GenericInMemoryCatalog.java    From flink with Apache License 2.0 5 votes vote down vote up
@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);
	}
}
 
Example #22
Source File: GenericInMemoryCatalog.java    From flink with Apache License 2.0 5 votes vote down vote up
@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);
	}
}
 
Example #23
Source File: CatalogTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testAlterPartition_PartitionNotExist() throws Exception {
	catalog.createDatabase(db1, createDb(), false);
	catalog.createTable(path1, createPartitionedTable(), false);

	CatalogPartitionSpec partitionSpec = createPartitionSpec();
	exception.expect(PartitionNotExistException.class);
	exception.expectMessage(
		String.format("Partition %s of table %s in catalog %s does not exist.",
			partitionSpec, path1.getFullName(), TEST_CATALOG_NAME));
	catalog.alterPartition(path1, partitionSpec, createPartition(), false);
}
 
Example #24
Source File: CatalogTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testAlterPartition_PartitionSpecInvalid() throws Exception {
	catalog.createDatabase(db1, createDb(), false);
	CatalogTable table = createPartitionedTable();
	catalog.createTable(path1, table, false);

	CatalogPartitionSpec partitionSpec = createInvalidPartitionSpecSubset();
	exception.expect(PartitionNotExistException.class);
	exception.expectMessage(
		String.format("Partition %s of table %s in catalog %s does not exist.",
			partitionSpec, path1.getFullName(), TEST_CATALOG_NAME));
	catalog.alterPartition(path1, partitionSpec, createPartition(), false);
}
 
Example #25
Source File: CatalogTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testAlterPartition_TableNotPartitioned() throws Exception {
	catalog.createDatabase(db1, createDb(), false);
	catalog.createTable(path1, createTable(), false);

	CatalogPartitionSpec partitionSpec = createPartitionSpec();
	exception.expect(PartitionNotExistException.class);
	exception.expectMessage(
		String.format("Partition %s of table %s in catalog %s does not exist.",
			partitionSpec, path1.getFullName(), TEST_CATALOG_NAME));
	catalog.alterPartition(path1, partitionSpec, createPartition(), false);
}
 
Example #26
Source File: CatalogTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testAlterPartition_TableNotExist() throws Exception {
	catalog.createDatabase(db1, createDb(), false);

	CatalogPartitionSpec partitionSpec = createPartitionSpec();
	exception.expect(PartitionNotExistException.class);
	exception.expectMessage(
		String.format("Partition %s of table %s in catalog %s does not exist.",
			partitionSpec, path1.getFullName(), TEST_CATALOG_NAME));
	catalog.alterPartition(path1, partitionSpec, createPartition(), false);
}
 
Example #27
Source File: CatalogTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testDropPartition_PartitionNotExist() throws Exception {
	catalog.createDatabase(db1, createDb(), false);
	catalog.createTable(path1, createPartitionedTable(), false);

	CatalogPartitionSpec partitionSpec = createPartitionSpec();
	exception.expect(PartitionNotExistException.class);
	exception.expectMessage(
		String.format("Partition %s of table %s in catalog %s does not exist.", partitionSpec, path1.getFullName(), TEST_CATALOG_NAME));
	catalog.dropPartition(path1, partitionSpec, false);
}
 
Example #28
Source File: CatalogTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testDropPartition_PartitionSpecInvalid() throws Exception {
	catalog.createDatabase(db1, createDb(), false);
	CatalogTable table = createPartitionedTable();
	catalog.createTable(path1, table, false);

	CatalogPartitionSpec partitionSpec = createInvalidPartitionSpecSubset();
	exception.expect(PartitionNotExistException.class);
	exception.expectMessage(
		String.format("Partition %s of table %s in catalog %s does not exist.",
			partitionSpec, path1.getFullName(), TEST_CATALOG_NAME));
	catalog.dropPartition(path1, partitionSpec, false);
}
 
Example #29
Source File: CatalogTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testDropPartition_TableNotPartitioned() throws Exception {
	catalog.createDatabase(db1, createDb(), false);
	catalog.createTable(path1, createTable(), false);

	CatalogPartitionSpec partitionSpec = createPartitionSpec();
	exception.expect(PartitionNotExistException.class);
	exception.expectMessage(
		String.format("Partition %s of table %s in catalog %s does not exist.",
			partitionSpec, path1.getFullName(), TEST_CATALOG_NAME));
	catalog.dropPartition(path1, partitionSpec, false);
}
 
Example #30
Source File: CatalogTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testDropPartition_TableNotExist() throws Exception {
	catalog.createDatabase(db1, createDb(), false);

	CatalogPartitionSpec partitionSpec = createPartitionSpec();
	exception.expect(PartitionNotExistException.class);
	exception.expectMessage(
		String.format("Partition %s of table %s in catalog %s does not exist.",
			partitionSpec, path1.getFullName(), TEST_CATALOG_NAME));
	catalog.dropPartition(path1, partitionSpec, false);
}