use of org.apache.flink.table.connector.source.DynamicTableSource in project flink by apache.
the class RegistryAvroFormatFactoryTest method testDeserializationSchemaWithOptionalProperties.
@Test
public void testDeserializationSchemaWithOptionalProperties() {
final AvroRowDataDeserializationSchema expectedDeser = new AvroRowDataDeserializationSchema(ConfluentRegistryAvroDeserializationSchema.forGeneric(AvroSchemaConverter.convertToSchema(ROW_TYPE), REGISTRY_URL, EXPECTED_OPTIONAL_PROPERTIES), AvroToRowDataConverters.createRowConverter(ROW_TYPE), InternalTypeInfo.of(ROW_TYPE));
final DynamicTableSource actualSource = createTableSource(SCHEMA, getOptionalProperties());
assertThat(actualSource, instanceOf(TestDynamicTableFactory.DynamicTableSourceMock.class));
TestDynamicTableFactory.DynamicTableSourceMock scanSourceMock = (TestDynamicTableFactory.DynamicTableSourceMock) actualSource;
DeserializationSchema<RowData> actualDeser = scanSourceMock.valueFormat.createRuntimeDecoder(ScanRuntimeProviderContext.INSTANCE, SCHEMA.toPhysicalRowDataType());
assertEquals(expectedDeser, actualDeser);
}
use of org.apache.flink.table.connector.source.DynamicTableSource in project flink by apache.
the class CsvFormatFactoryTest method createDeserializationSchema.
private static DeserializationSchema<RowData> createDeserializationSchema(Map<String, String> options) {
final DynamicTableSource actualSource = createTableSource(SCHEMA, options);
assert actualSource instanceof TestDynamicTableFactory.DynamicTableSourceMock;
TestDynamicTableFactory.DynamicTableSourceMock sourceMock = (TestDynamicTableFactory.DynamicTableSourceMock) actualSource;
return sourceMock.valueFormat.createRuntimeDecoder(ScanRuntimeProviderContext.INSTANCE, PHYSICAL_DATA_TYPE);
}
use of org.apache.flink.table.connector.source.DynamicTableSource in project flink by apache.
the class HiveTableFactoryTest method testHiveTable.
@Test
public void testHiveTable() throws Exception {
final ResolvedSchema schema = ResolvedSchema.of(Column.physical("name", DataTypes.STRING()), Column.physical("age", DataTypes.INT()));
catalog.createDatabase("mydb", new CatalogDatabaseImpl(new HashMap<>(), ""), true);
final Map<String, String> options = Collections.singletonMap(FactoryUtil.CONNECTOR.key(), SqlCreateHiveTable.IDENTIFIER);
final CatalogTable table = new CatalogTableImpl(TableSchema.fromResolvedSchema(schema), options, "hive table");
catalog.createTable(new ObjectPath("mydb", "mytable"), table, true);
final DynamicTableSource tableSource = FactoryUtil.createDynamicTableSource((DynamicTableSourceFactory) catalog.getFactory().orElseThrow(IllegalStateException::new), ObjectIdentifier.of("mycatalog", "mydb", "mytable"), new ResolvedCatalogTable(table, schema), new Configuration(), Thread.currentThread().getContextClassLoader(), false);
assertTrue(tableSource instanceof HiveTableSource);
final DynamicTableSink tableSink = FactoryUtil.createDynamicTableSink((DynamicTableSinkFactory) catalog.getFactory().orElseThrow(IllegalStateException::new), ObjectIdentifier.of("mycatalog", "mydb", "mytable"), new ResolvedCatalogTable(table, schema), new Configuration(), Thread.currentThread().getContextClassLoader(), false);
assertTrue(tableSink instanceof HiveTableSink);
}
use of org.apache.flink.table.connector.source.DynamicTableSource in project flink by apache.
the class CanalJsonFormatFactoryTest method createDeserializationSchema.
private static DeserializationSchema<RowData> createDeserializationSchema(Map<String, String> options) {
DynamicTableSource source = createTableSource(SCHEMA, options);
assert source instanceof TestDynamicTableFactory.DynamicTableSourceMock;
TestDynamicTableFactory.DynamicTableSourceMock scanSourceMock = (TestDynamicTableFactory.DynamicTableSourceMock) source;
return scanSourceMock.valueFormat.createRuntimeDecoder(ScanRuntimeProviderContext.INSTANCE, PHYSICAL_DATA_TYPE);
}
use of org.apache.flink.table.connector.source.DynamicTableSource in project flink by apache.
the class JdbcDynamicTableFactoryTest method testJdbcLookupPropertiesWithExcludeEmptyResult.
@Test
public void testJdbcLookupPropertiesWithExcludeEmptyResult() {
Map<String, String> properties = getAllOptions();
properties.put("lookup.cache.max-rows", "1000");
properties.put("lookup.cache.ttl", "10s");
properties.put("lookup.max-retries", "10");
properties.put("lookup.cache.caching-missing-key", "true");
DynamicTableSource actual = createTableSource(SCHEMA, properties);
JdbcConnectorOptions options = JdbcConnectorOptions.builder().setDBUrl("jdbc:derby:memory:mydb").setTableName("mytable").build();
JdbcLookupOptions lookupOptions = JdbcLookupOptions.builder().setCacheMaxSize(1000).setCacheExpireMs(10_000).setMaxRetryTimes(10).setCacheMissingKey(true).build();
JdbcDynamicTableSource expected = new JdbcDynamicTableSource(options, JdbcReadOptions.builder().build(), lookupOptions, SCHEMA.toPhysicalRowDataType());
assertEquals(expected, actual);
}
Aggregations