Search in sources :

Example 1 with RowData

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();
}
Also used : KinesisDataStreamsConnectorOptionsUtils(org.apache.flink.connector.kinesis.table.util.KinesisDataStreamsConnectorOptionsUtils) RowData(org.apache.flink.table.data.RowData) Properties(java.util.Properties)

Example 2 with RowData

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);
}
Also used : SinkRuntimeProviderContext(org.apache.flink.table.runtime.connector.sink.SinkRuntimeProviderContext) RowData(org.apache.flink.table.data.RowData) SinkV2Provider(org.apache.flink.table.connector.sink.SinkV2Provider) DynamicTableSink(org.apache.flink.table.connector.sink.DynamicTableSink) ResolvedSchema(org.apache.flink.table.catalog.ResolvedSchema) Test(org.junit.Test)

Example 3 with RowData

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);
}
Also used : SinkRuntimeProviderContext(org.apache.flink.table.runtime.connector.sink.SinkRuntimeProviderContext) RowData(org.apache.flink.table.data.RowData) SinkV2Provider(org.apache.flink.table.connector.sink.SinkV2Provider) DynamicTableSink(org.apache.flink.table.connector.sink.DynamicTableSink) ResolvedSchema(org.apache.flink.table.catalog.ResolvedSchema) Test(org.junit.Test)

Example 4 with RowData

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);
}
Also used : SinkRuntimeProviderContext(org.apache.flink.table.runtime.connector.sink.SinkRuntimeProviderContext) DynamicTableSink(org.apache.flink.table.connector.sink.DynamicTableSink) RowData(org.apache.flink.table.data.RowData) SinkV2Provider(org.apache.flink.table.connector.sink.SinkV2Provider) ResolvedSchema(org.apache.flink.table.catalog.ResolvedSchema) Test(org.junit.Test)

Example 5 with RowData

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);
}
Also used : SinkRuntimeProviderContext(org.apache.flink.table.runtime.connector.sink.SinkRuntimeProviderContext) RowData(org.apache.flink.table.data.RowData) SinkV2Provider(org.apache.flink.table.connector.sink.SinkV2Provider) DynamicTableSink(org.apache.flink.table.connector.sink.DynamicTableSink) ResolvedSchema(org.apache.flink.table.catalog.ResolvedSchema) Test(org.junit.Test)

Aggregations

RowData (org.apache.flink.table.data.RowData)602 Test (org.junit.Test)201 GenericRowData (org.apache.flink.table.data.GenericRowData)178 ArrayList (java.util.ArrayList)109 RowType (org.apache.flink.table.types.logical.RowType)105 JoinedRowData (org.apache.flink.table.data.utils.JoinedRowData)90 Watermark (org.apache.flink.streaming.api.watermark.Watermark)84 ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)72 Transformation (org.apache.flink.api.dag.Transformation)70 Configuration (org.apache.flink.configuration.Configuration)68 BinaryRowData (org.apache.flink.table.data.binary.BinaryRowData)67 List (java.util.List)65 ExecEdge (org.apache.flink.table.planner.plan.nodes.exec.ExecEdge)54 DataType (org.apache.flink.table.types.DataType)52 Map (java.util.Map)42 LogicalType (org.apache.flink.table.types.logical.LogicalType)41 TableException (org.apache.flink.table.api.TableException)34 OneInputTransformation (org.apache.flink.streaming.api.transformations.OneInputTransformation)33 RowDataKeySelector (org.apache.flink.table.runtime.keyselector.RowDataKeySelector)32 OperatorSubtaskState (org.apache.flink.runtime.checkpoint.OperatorSubtaskState)31