use of org.apache.flink.connector.jdbc.split.JdbcGenericParameterValuesProvider in project flink by apache.
the class JdbcRowDataInputFormatTest method testJdbcInputFormatWithParallelismAndGenericSplitting.
@Test
public void testJdbcInputFormatWithParallelismAndGenericSplitting() throws IOException {
Serializable[][] queryParameters = new String[2][1];
queryParameters[0] = new String[] { TEST_DATA[3].author };
queryParameters[1] = new String[] { TEST_DATA[0].author };
JdbcParameterValuesProvider paramProvider = new JdbcGenericParameterValuesProvider(queryParameters);
inputFormat = JdbcRowDataInputFormat.builder().setDrivername(DERBY_EBOOKSHOP_DB.getDriverClass()).setDBUrl(DERBY_EBOOKSHOP_DB.getUrl()).setQuery(SELECT_ALL_BOOKS_SPLIT_BY_AUTHOR).setParametersProvider(paramProvider).setResultSetType(ResultSet.TYPE_SCROLL_INSENSITIVE).setRowConverter(dialect.getRowConverter(rowType)).build();
inputFormat.openInputFormat();
InputSplit[] splits = inputFormat.createInputSplits(1);
// this query exploit parallelism (1 split for every queryParameters row)
Assert.assertEquals(queryParameters.length, splits.length);
verifySplit(splits[0], TEST_DATA[3].id);
verifySplit(splits[1], TEST_DATA[0].id + TEST_DATA[1].id);
inputFormat.closeInputFormat();
}
use of org.apache.flink.connector.jdbc.split.JdbcGenericParameterValuesProvider in project flink by apache.
the class JdbcInputFormatTest method testJdbcInputFormatWithParallelismAndGenericSplitting.
@Test
public void testJdbcInputFormatWithParallelismAndGenericSplitting() throws IOException {
Serializable[][] queryParameters = new String[2][1];
queryParameters[0] = new String[] { TEST_DATA[3].author };
queryParameters[1] = new String[] { TEST_DATA[0].author };
JdbcParameterValuesProvider paramProvider = new JdbcGenericParameterValuesProvider(queryParameters);
jdbcInputFormat = JdbcInputFormat.buildJdbcInputFormat().setDrivername(DERBY_EBOOKSHOP_DB.getDriverClass()).setDBUrl(DERBY_EBOOKSHOP_DB.getUrl()).setQuery(SELECT_ALL_BOOKS_SPLIT_BY_AUTHOR).setRowTypeInfo(ROW_TYPE_INFO).setParametersProvider(paramProvider).setResultSetType(ResultSet.TYPE_SCROLL_INSENSITIVE).finish();
jdbcInputFormat.openInputFormat();
InputSplit[] splits = jdbcInputFormat.createInputSplits(1);
// this query exploit parallelism (1 split for every queryParameters row)
Assert.assertEquals(queryParameters.length, splits.length);
verifySplit(splits[0], TEST_DATA[3].id);
verifySplit(splits[1], TEST_DATA[0].id + TEST_DATA[1].id);
jdbcInputFormat.closeInputFormat();
}
Aggregations