use of org.apache.flink.table.data.RowData in project flink by apache.
the class KinesisDynamicTableSinkFactory method createDynamicTableSink.
@Override
public DynamicTableSink createDynamicTableSink(Context context) {
AsyncDynamicSinkContext factoryContext = new AsyncDynamicSinkContext(this, context);
KinesisDataStreamsConnectorOptionsUtils optionsUtils = new KinesisDataStreamsConnectorOptionsUtils(factoryContext.getResolvedOptions(), factoryContext.getTableOptions(), (RowType) factoryContext.getPhysicalDataType().getLogicalType(), factoryContext.getPartitionKeys(), context.getClassLoader());
// validate the data types of the table options
factoryContext.getFactoryHelper().validateExcept(optionsUtils.getNonValidatedPrefixes().toArray(new String[0]));
// Validate option values
validateKinesisPartitioner(factoryContext.getTableOptions(), factoryContext.isPartitioned());
Properties properties = optionsUtils.getValidatedSinkConfigurations();
KinesisDynamicSink.KinesisDynamicTableSinkBuilder builder = new KinesisDynamicSink.KinesisDynamicTableSinkBuilder();
builder.setStream((String) properties.get(STREAM.key())).setKinesisClientProperties((Properties) properties.get(KINESIS_CLIENT_PROPERTIES_KEY)).setEncodingFormat(factoryContext.getEncodingFormat()).setConsumedDataType(factoryContext.getPhysicalDataType()).setPartitioner((PartitionKeyGenerator<RowData>) properties.get(SINK_PARTITIONER.key()));
addAsyncOptionsToBuilder(properties, builder);
Optional.ofNullable((Boolean) properties.get(SINK_FAIL_ON_ERROR.key())).ifPresent(builder::setFailOnError);
return builder.build();
}
use of org.apache.flink.table.data.RowData in project flink by apache.
the class KinesisFirehoseDynamicTableFactoryTest method testGoodTableSink.
@Test
public void testGoodTableSink() {
ResolvedSchema sinkSchema = defaultSinkSchema();
Map<String, String> sinkOptions = defaultTableOptions().build();
// Construct actual DynamicTableSink using FactoryUtil
KinesisFirehoseDynamicSink actualSink = (KinesisFirehoseDynamicSink) createTableSink(sinkSchema, sinkOptions);
// Construct expected DynamicTableSink using factory under test
KinesisFirehoseDynamicSink expectedSink = new KinesisFirehoseDynamicSink.KinesisDataFirehoseDynamicSinkBuilder().setConsumedDataType(sinkSchema.toPhysicalRowDataType()).setDeliveryStream(DELIVERY_STREAM_NAME).setFirehoseClientProperties(defaultSinkProperties()).setEncodingFormat(new TestFormatFactory.EncodingFormatMock(",")).build();
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(KinesisFirehoseSink.class);
}
use of org.apache.flink.table.data.RowData in project flink by apache.
the class KinesisFirehoseDynamicTableFactoryTest method testGoodTableSinkWithSinkOptions.
@Test
public void testGoodTableSinkWithSinkOptions() {
ResolvedSchema sinkSchema = defaultSinkSchema();
Map<String, String> sinkOptions = defaultTableOptionsWithSinkOptions().build();
// Construct actual DynamicTableSink using FactoryUtil
KinesisFirehoseDynamicSink actualSink = (KinesisFirehoseDynamicSink) createTableSink(sinkSchema, sinkOptions);
// Construct expected DynamicTableSink using factory under test
KinesisFirehoseDynamicSink expectedSink = getDefaultSinkBuilder().setConsumedDataType(sinkSchema.toPhysicalRowDataType()).setDeliveryStream(DELIVERY_STREAM_NAME).setFirehoseClientProperties(defaultSinkProperties()).setEncodingFormat(new TestFormatFactory.EncodingFormatMock(",")).build();
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(KinesisFirehoseSink.class);
}
use of org.apache.flink.table.data.RowData in project flink by apache.
the class KinesisDynamicTableSinkFactoryTest method testGoodTableSinkForNonPartitionedTable.
@Test
public void testGoodTableSinkForNonPartitionedTable() {
ResolvedSchema sinkSchema = defaultSinkSchema();
Map<String, String> sinkOptions = defaultTableOptions().build();
// Construct actual DynamicTableSink using FactoryUtil
KinesisDynamicSink actualSink = (KinesisDynamicSink) createTableSink(sinkSchema, sinkOptions);
// Construct expected DynamicTableSink using factory under test
KinesisDynamicSink expectedSink = (KinesisDynamicSink) new KinesisDynamicSink.KinesisDynamicTableSinkBuilder().setConsumedDataType(sinkSchema.toPhysicalRowDataType()).setStream(STREAM_NAME).setKinesisClientProperties(defaultProducerProperties()).setEncodingFormat(new TestFormatFactory.EncodingFormatMock(",")).setPartitioner(new RandomKinesisPartitionKeyGenerator<>()).build();
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.data.RowData in project flink by apache.
the class KinesisDynamicTableSinkFactoryTest method testGoodTableSinkForNonPartitionedTableWithSinkOptions.
@Test
public void testGoodTableSinkForNonPartitionedTableWithSinkOptions() {
ResolvedSchema sinkSchema = defaultSinkSchema();
Map<String, String> sinkOptions = defaultTableOptionsWithSinkOptions().build();
// Construct actual DynamicTableSink using FactoryUtil
KinesisDynamicSink actualSink = (KinesisDynamicSink) createTableSink(sinkSchema, sinkOptions);
// Construct expected DynamicTableSink using factory under test
KinesisDynamicSink expectedSink = (KinesisDynamicSink) getDefaultSinkBuilder().setConsumedDataType(sinkSchema.toPhysicalRowDataType()).setStream(STREAM_NAME).setKinesisClientProperties(defaultProducerProperties()).setEncodingFormat(new TestFormatFactory.EncodingFormatMock(",")).setPartitioner(new RandomKinesisPartitionKeyGenerator<>()).build();
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);
}
Aggregations