use of org.apache.flink.table.catalog.ResolvedSchema in project flink by apache.
the class KinesisDynamicTableSinkFactoryTest method testGoodTableSinkForPartitionedTable.
@Test
public void testGoodTableSinkForPartitionedTable() {
ResolvedSchema sinkSchema = defaultSinkSchema();
DataType physicalDataType = sinkSchema.toPhysicalRowDataType();
Map<String, String> sinkOptions = defaultTableOptions().build();
List<String> sinkPartitionKeys = Arrays.asList("name", "curr_id");
// Construct actual DynamicTableSink using FactoryUtil
KinesisDynamicSink actualSink = (KinesisDynamicSink) createTableSink(sinkSchema, sinkPartitionKeys, sinkOptions);
// Construct expected DynamicTableSink using factory under test
KinesisDynamicSink expectedSink = (KinesisDynamicSink) new KinesisDynamicSink.KinesisDynamicTableSinkBuilder().setConsumedDataType(physicalDataType).setStream(STREAM_NAME).setKinesisClientProperties(defaultProducerProperties()).setEncodingFormat(new TestFormatFactory.EncodingFormatMock(",")).setPartitioner(new RowDataFieldsKinesisPartitionKeyGenerator((RowType) physicalDataType.getLogicalType(), sinkPartitionKeys)).build();
// verify that the constructed DynamicTableSink is as expected
Assertions.assertThat(actualSink).isEqualTo(expectedSink);
// verify the produced sink
DynamicTableSink.SinkRuntimeProvider sinkFunctionProvider = actualSink.getSinkRuntimeProvider(new SinkRuntimeProviderContext(false));
Sink<RowData> sinkFunction = ((SinkV2Provider) sinkFunctionProvider).createSink();
Assertions.assertThat(sinkFunction).isInstanceOf(KinesisDataStreamsSink.class);
}
use of org.apache.flink.table.catalog.ResolvedSchema in project flink by apache.
the class HBaseDynamicTableFactoryTest method testParallelismOptions.
@Test
public void testParallelismOptions() {
Map<String, String> options = getAllOptions();
options.put("sink.parallelism", "2");
ResolvedSchema schema = ResolvedSchema.of(Column.physical(ROWKEY, STRING()));
DynamicTableSink sink = createTableSink(schema, options);
assertTrue(sink instanceof HBaseDynamicTableSink);
HBaseDynamicTableSink hbaseSink = (HBaseDynamicTableSink) sink;
SinkFunctionProvider provider = (SinkFunctionProvider) hbaseSink.getSinkRuntimeProvider(new SinkRuntimeProviderContext(false));
assertEquals(2, (long) provider.getParallelism().get());
}
use of org.apache.flink.table.catalog.ResolvedSchema in project flink by apache.
the class HBaseDynamicTableFactoryTest method testLookupOptions.
@Test
public void testLookupOptions() {
Map<String, String> options = getAllOptions();
options.put("lookup.cache.max-rows", "1000");
options.put("lookup.cache.ttl", "10s");
options.put("lookup.max-retries", "10");
ResolvedSchema schema = ResolvedSchema.of(Column.physical(ROWKEY, STRING()), Column.physical(FAMILY1, ROW(FIELD(COL1, DOUBLE()), FIELD(COL2, INT()))));
DynamicTableSource source = createTableSource(schema, options);
HBaseLookupOptions actual = ((HBaseDynamicTableSource) source).getLookupOptions();
HBaseLookupOptions expected = HBaseLookupOptions.builder().setCacheMaxSize(1000).setCacheExpireMs(10_000).setMaxRetryTimes(10).build();
assertEquals(expected, actual);
}
use of org.apache.flink.table.catalog.ResolvedSchema in project flink by apache.
the class HBaseDynamicTableFactoryTest method testDisabledBufferFlushOptions.
@Test
public void testDisabledBufferFlushOptions() {
Map<String, String> options = getAllOptions();
options.put("sink.buffer-flush.max-size", "0");
options.put("sink.buffer-flush.max-rows", "0");
options.put("sink.buffer-flush.interval", "0");
ResolvedSchema schema = ResolvedSchema.of(Column.physical(ROWKEY, STRING()));
DynamicTableSink sink = createTableSink(schema, options);
HBaseWriteOptions expected = HBaseWriteOptions.builder().setBufferFlushMaxRows(0).setBufferFlushIntervalMillis(0).setBufferFlushMaxSizeInBytes(0).build();
HBaseWriteOptions actual = ((HBaseDynamicTableSink) sink).getWriteOptions();
assertEquals(expected, actual);
}
use of org.apache.flink.table.catalog.ResolvedSchema in project flink by apache.
the class HBaseDynamicTableFactoryTest method testDisabledBufferFlushOptions.
@Test
public void testDisabledBufferFlushOptions() {
Map<String, String> options = getAllOptions();
options.put("sink.buffer-flush.max-size", "0");
options.put("sink.buffer-flush.max-rows", "0");
options.put("sink.buffer-flush.interval", "0");
ResolvedSchema schema = ResolvedSchema.of(Column.physical(ROWKEY, STRING()));
DynamicTableSink sink = createTableSink(schema, options);
HBaseWriteOptions expected = HBaseWriteOptions.builder().setBufferFlushMaxRows(0).setBufferFlushIntervalMillis(0).setBufferFlushMaxSizeInBytes(0).build();
HBaseWriteOptions actual = ((HBaseDynamicTableSink) sink).getWriteOptions();
assertEquals(expected, actual);
}
Aggregations