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

The following examples show how to use org.apache.flink.table.catalog.exceptions.PartitionNotExistException. These examples are extracted from open source projects. 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 Project: flink   Source File: CatalogTest.java    License: 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 2
Source Project: flink   Source File: GenericInMemoryCatalog.java    License: 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 3
Source Project: flink   Source File: CatalogTest.java    License: 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 4
Source Project: flink   Source File: GenericInMemoryCatalog.java    License: 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 5
Source Project: flink   Source File: CatalogTest.java    License: 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);
}
 
Example 6
Source Project: flink   Source File: CatalogTest.java    License: 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 7
Source Project: flink   Source File: CatalogTest.java    License: 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 8
Source Project: flink   Source File: CatalogTest.java    License: 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 9
Source Project: flink   Source File: CatalogTest.java    License: 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 10
Source Project: flink   Source File: CatalogTest.java    License: 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 11
Source Project: flink   Source File: CatalogTest.java    License: 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 12
Source Project: flink   Source File: CatalogTest.java    License: 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 13
Source Project: flink   Source File: CatalogTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testGetPartition_TableNotExist() throws Exception {
	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 Project: flink   Source File: CatalogTest.java    License: 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 15
Source Project: flink   Source File: CatalogTest.java    License: 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 16
Source Project: flink   Source File: CatalogTest.java    License: 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 17
Source Project: flink   Source File: GenericInMemoryCatalog.java    License: 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 18
Source Project: flink   Source File: GenericInMemoryCatalog.java    License: 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 19
Source Project: flink   Source File: GenericInMemoryCatalog.java    License: 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 Project: flink   Source File: GenericInMemoryCatalog.java    License: 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 Project: flink   Source File: GenericInMemoryCatalog.java    License: 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 Project: flink   Source File: GenericInMemoryCatalog.java    License: 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 Project: flink   Source File: CatalogTest.java    License: 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);
}
 
Example 24
Source Project: flink   Source File: CatalogTest.java    License: 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 25
Source Project: flink   Source File: CatalogTest.java    License: 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 26
Source Project: flink   Source File: CatalogTest.java    License: 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 27
Source Project: flink   Source File: CatalogTest.java    License: 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 28
Source Project: flink   Source File: CatalogTest.java    License: 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 29
Source Project: flink   Source File: CatalogTest.java    License: 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 30
Source Project: flink   Source File: CatalogTest.java    License: 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);
}