Search in sources :

Example 1 with Metadata

use of org.apache.flink.streaming.connectors.kinesis.table.RowDataKinesisDeserializationSchema.Metadata in project flink by apache.

the class KinesisDynamicTableFactoryTest method testGoodTableSourceWithMetadataFields.

@Test
public void testGoodTableSourceWithMetadataFields() {
    ResolvedSchema sourceSchema = defaultSourceSchema();
    Map<String, String> sourceOptions = defaultTableOptions().build();
    Metadata[] requestedMetadata = new Metadata[] { ShardId, Timestamp };
    List<String> metadataKeys = Arrays.asList(ShardId.getFieldName(), Timestamp.getFieldName());
    DataType producedDataType = getProducedType(sourceSchema, requestedMetadata);
    // Construct actual DynamicTableSource using FactoryUtil
    KinesisDynamicSource actualSource = (KinesisDynamicSource) createTableSource(sourceSchema, sourceOptions);
    actualSource.applyReadableMetadata(metadataKeys, producedDataType);
    // Construct expected DynamicTableSink using factory under test
    KinesisDynamicSource expectedSource = new KinesisDynamicSource(sourceSchema.toPhysicalRowDataType(), STREAM_NAME, defaultConsumerProperties(), new TestFormatFactory.DecodingFormatMock(",", true), producedDataType, Arrays.asList(requestedMetadata));
    // verify that the constructed DynamicTableSource is as expected
    assertEquals(expectedSource, actualSource);
    // verify that the copy of the constructed DynamicTableSink is as expected
    assertEquals(expectedSource, actualSource.copy());
}
Also used : Metadata(org.apache.flink.streaming.connectors.kinesis.table.RowDataKinesisDeserializationSchema.Metadata) DataType(org.apache.flink.table.types.DataType) TestFormatFactory(org.apache.flink.table.factories.TestFormatFactory) ResolvedSchema(org.apache.flink.table.catalog.ResolvedSchema) Test(org.junit.Test)

Aggregations

Metadata (org.apache.flink.streaming.connectors.kinesis.table.RowDataKinesisDeserializationSchema.Metadata)1 ResolvedSchema (org.apache.flink.table.catalog.ResolvedSchema)1 TestFormatFactory (org.apache.flink.table.factories.TestFormatFactory)1 DataType (org.apache.flink.table.types.DataType)1 Test (org.junit.Test)1