use of org.apache.flink.table.descriptors.DescriptorProperties in project flink by apache.
the class FileSystemTableFactoryTest method testFormatOptionsError.
@Test
public void testFormatOptionsError() {
DescriptorProperties descriptor = new DescriptorProperties();
descriptor.putString(FactoryUtil.CONNECTOR.key(), "filesystem");
descriptor.putString("path", "/tmp");
descriptor.putString("format", "test-format");
Exception expected = new ValidationException("One or more required options are missing.\n\n" + "Missing required options are:\n\n" + "delimiter");
try {
createTableSource(SCHEMA, descriptor.asMap());
fail("Should fail");
} catch (Exception e) {
assertThat(e.getCause().getCause(), containsCause(expected));
}
try {
createTableSink(SCHEMA, descriptor.asMap());
fail("Should fail");
} catch (Exception e) {
assertThat(e.getCause().getCause(), containsCause(expected));
}
}
use of org.apache.flink.table.descriptors.DescriptorProperties in project flink by apache.
the class FlinkCalciteCatalogReader method isLegacySourceOptions.
/**
* Checks whether the {@link CatalogTable} uses legacy connector source options.
*/
private static boolean isLegacySourceOptions(CatalogSchemaTable schemaTable) {
// normalize option keys
DescriptorProperties properties = new DescriptorProperties(true);
properties.putProperties(schemaTable.getContextResolvedTable().getTable().getOptions());
if (properties.containsKey(ConnectorDescriptorValidator.CONNECTOR_TYPE)) {
return true;
} else {
// some legacy factories uses the new 'connector' key
try {
TableFactoryUtil.findAndCreateTableSource(schemaTable.getContextResolvedTable().getCatalog().orElse(null), schemaTable.getContextResolvedTable().getIdentifier(), schemaTable.getContextResolvedTable().getTable(), new Configuration(), schemaTable.isTemporary());
// success, then we will use the legacy factories
return true;
} catch (Throwable e) {
// fail, then we will use new factories
return false;
}
}
}
Aggregations