Search in sources :

Example 1 with OutputConversionOperator

use of org.apache.flink.table.runtime.operators.sink.OutputConversionOperator in project flink by apache.

the class ExternalDynamicSink method getSinkRuntimeProvider.

@Override
public SinkRuntimeProvider getSinkRuntimeProvider(Context context) {
    final DynamicTableSink.DataStructureConverter physicalConverter = context.createDataStructureConverter(physicalDataType);
    return (TransformationSinkProvider) transformationContext -> {
        final Transformation<RowData> input = transformationContext.getInputTransformation();
        final LogicalType physicalType = physicalDataType.getLogicalType();
        final RowData.FieldGetter atomicFieldGetter;
        if (LogicalTypeChecks.isCompositeType(physicalType)) {
            atomicFieldGetter = null;
        } else {
            atomicFieldGetter = RowData.createFieldGetter(physicalType, 0);
        }
        TransformationMetadata transformationMeta = transformationContext.generateUid(EXTERNAL_DATASTREAM_TRANSFORMATION).map(uid -> new TransformationMetadata(uid, generateOperatorName(), generateOperatorDesc())).orElseGet(() -> new TransformationMetadata(generateOperatorName(), generateOperatorDesc()));
        return ExecNodeUtil.createOneInputTransformation(input, transformationMeta, new OutputConversionOperator(atomicFieldGetter, physicalConverter, transformationContext.getRowtimeIndex(), consumeRowtimeMetadata), ExternalTypeInfo.of(physicalDataType), input.getParallelism());
    };
}
Also used : TransformationMetadata(org.apache.flink.table.planner.plan.nodes.exec.utils.TransformationMetadata) DataType(org.apache.flink.table.types.DataType) OutputConversionOperator(org.apache.flink.table.runtime.operators.sink.OutputConversionOperator) RowData(org.apache.flink.table.data.RowData) DynamicTableSink(org.apache.flink.table.connector.sink.DynamicTableSink) ChangelogMode(org.apache.flink.table.connector.ChangelogMode) SupportsWritingMetadata(org.apache.flink.table.connector.sink.abilities.SupportsWritingMetadata) DataTypes(org.apache.flink.table.api.DataTypes) ExternalTypeInfo(org.apache.flink.table.runtime.typeutils.ExternalTypeInfo) DataStream(org.apache.flink.streaming.api.datastream.DataStream) ExecNodeUtil(org.apache.flink.table.planner.plan.nodes.exec.utils.ExecNodeUtil) List(java.util.List) LogicalType(org.apache.flink.table.types.logical.LogicalType) Map(java.util.Map) Internal(org.apache.flink.annotation.Internal) Transformation(org.apache.flink.api.dag.Transformation) Collections(java.util.Collections) Nullable(javax.annotation.Nullable) LogicalTypeChecks(org.apache.flink.table.types.logical.utils.LogicalTypeChecks) RowData(org.apache.flink.table.data.RowData) TransformationMetadata(org.apache.flink.table.planner.plan.nodes.exec.utils.TransformationMetadata) OutputConversionOperator(org.apache.flink.table.runtime.operators.sink.OutputConversionOperator) LogicalType(org.apache.flink.table.types.logical.LogicalType) DynamicTableSink(org.apache.flink.table.connector.sink.DynamicTableSink)

Aggregations

Collections (java.util.Collections)1 List (java.util.List)1 Map (java.util.Map)1 Nullable (javax.annotation.Nullable)1 Internal (org.apache.flink.annotation.Internal)1 Transformation (org.apache.flink.api.dag.Transformation)1 DataStream (org.apache.flink.streaming.api.datastream.DataStream)1 DataTypes (org.apache.flink.table.api.DataTypes)1 ChangelogMode (org.apache.flink.table.connector.ChangelogMode)1 DynamicTableSink (org.apache.flink.table.connector.sink.DynamicTableSink)1 SupportsWritingMetadata (org.apache.flink.table.connector.sink.abilities.SupportsWritingMetadata)1 RowData (org.apache.flink.table.data.RowData)1 ExecNodeUtil (org.apache.flink.table.planner.plan.nodes.exec.utils.ExecNodeUtil)1 TransformationMetadata (org.apache.flink.table.planner.plan.nodes.exec.utils.TransformationMetadata)1 OutputConversionOperator (org.apache.flink.table.runtime.operators.sink.OutputConversionOperator)1 ExternalTypeInfo (org.apache.flink.table.runtime.typeutils.ExternalTypeInfo)1 DataType (org.apache.flink.table.types.DataType)1 LogicalType (org.apache.flink.table.types.logical.LogicalType)1 LogicalTypeChecks (org.apache.flink.table.types.logical.utils.LogicalTypeChecks)1