Search in sources :

Example 1 with JdbcReadOptions

use of org.apache.flink.connector.jdbc.internal.options.JdbcReadOptions in project flink by apache.

the class JdbcDynamicTableFactoryTest method testJdbcReadProperties.

@Test
public void testJdbcReadProperties() {
    Map<String, String> properties = getAllOptions();
    properties.put("scan.partition.column", "aaa");
    properties.put("scan.partition.lower-bound", "-10");
    properties.put("scan.partition.upper-bound", "100");
    properties.put("scan.partition.num", "10");
    properties.put("scan.fetch-size", "20");
    properties.put("scan.auto-commit", "false");
    DynamicTableSource actual = createTableSource(SCHEMA, properties);
    JdbcConnectorOptions options = JdbcConnectorOptions.builder().setDBUrl("jdbc:derby:memory:mydb").setTableName("mytable").build();
    JdbcReadOptions readOptions = JdbcReadOptions.builder().setPartitionColumnName("aaa").setPartitionLowerBound(-10).setPartitionUpperBound(100).setNumPartitions(10).setFetchSize(20).setAutoCommit(false).build();
    JdbcLookupOptions lookupOptions = JdbcLookupOptions.builder().setCacheMaxSize(-1).setCacheExpireMs(10_000).setMaxRetryTimes(3).build();
    JdbcDynamicTableSource expected = new JdbcDynamicTableSource(options, readOptions, lookupOptions, SCHEMA.toPhysicalRowDataType());
    assertEquals(expected, actual);
}
Also used : JdbcLookupOptions(org.apache.flink.connector.jdbc.internal.options.JdbcLookupOptions) JdbcConnectorOptions(org.apache.flink.connector.jdbc.internal.options.JdbcConnectorOptions) JdbcReadOptions(org.apache.flink.connector.jdbc.internal.options.JdbcReadOptions) DynamicTableSource(org.apache.flink.table.connector.source.DynamicTableSource) Test(org.junit.Test)

Aggregations

JdbcConnectorOptions (org.apache.flink.connector.jdbc.internal.options.JdbcConnectorOptions)1 JdbcLookupOptions (org.apache.flink.connector.jdbc.internal.options.JdbcLookupOptions)1 JdbcReadOptions (org.apache.flink.connector.jdbc.internal.options.JdbcReadOptions)1 DynamicTableSource (org.apache.flink.table.connector.source.DynamicTableSource)1 Test (org.junit.Test)1