Search in sources :

Example 1 with KinesisDynamicSink

use of org.apache.flink.connector.kinesis.table.KinesisDynamicSink in project flink by apache.

the class KinesisDynamicTableFactoryTest method testGoodTableSinkCopyForPartitionedTable.

@Test
public void testGoodTableSinkCopyForPartitionedTable() {
    ResolvedSchema sinkSchema = defaultSinkSchema();
    DataType physicalDataType = sinkSchema.toPhysicalRowDataType();
    Map<String, String> sinkOptions = defaultSinkTableOptions().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();
    Assertions.assertThat(actualSink).isEqualTo(expectedSink.copy());
    Assertions.assertThat(expectedSink).isNotSameAs(expectedSink.copy());
}
Also used : RowDataFieldsKinesisPartitionKeyGenerator(org.apache.flink.connector.kinesis.table.RowDataFieldsKinesisPartitionKeyGenerator) KinesisDynamicSink(org.apache.flink.connector.kinesis.table.KinesisDynamicSink) DataType(org.apache.flink.table.types.DataType) RowType(org.apache.flink.table.types.logical.RowType) ResolvedSchema(org.apache.flink.table.catalog.ResolvedSchema) Test(org.junit.Test)

Aggregations

KinesisDynamicSink (org.apache.flink.connector.kinesis.table.KinesisDynamicSink)1 RowDataFieldsKinesisPartitionKeyGenerator (org.apache.flink.connector.kinesis.table.RowDataFieldsKinesisPartitionKeyGenerator)1 ResolvedSchema (org.apache.flink.table.catalog.ResolvedSchema)1 DataType (org.apache.flink.table.types.DataType)1 RowType (org.apache.flink.table.types.logical.RowType)1 Test (org.junit.Test)1