Search in sources :

Example 1 with StreamRecordTimestampInserter

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

the class StreamExecMatch method translateOrder.

private Transformation<RowData> translateOrder(Transformation<RowData> inputTransform, RowType inputRowType) {
    SortSpec.SortFieldSpec timeOrderField = matchSpec.getOrderKeys().getFieldSpec(0);
    int timeOrderFieldIdx = timeOrderField.getFieldIndex();
    LogicalType timeOrderFieldType = inputRowType.getTypeAt(timeOrderFieldIdx);
    if (TypeCheckUtils.isRowTime(timeOrderFieldType)) {
        // copy the rowtime field into the StreamRecord timestamp field
        int precision = getPrecision(timeOrderFieldType);
        Transformation<RowData> transform = ExecNodeUtil.createOneInputTransformation(inputTransform, new TransformationMetadata(createTransformationUid(TIMESTAMP_INSERTER_TRANSFORMATION), "StreamRecordTimestampInserter", String.format("StreamRecordTimestampInserter(rowtime field: %s)", timeOrderFieldIdx)), new StreamRecordTimestampInserter(timeOrderFieldIdx, precision), inputTransform.getOutputType(), inputTransform.getParallelism());
        if (inputsContainSingleton()) {
            transform.setParallelism(1);
            transform.setMaxParallelism(1);
        }
        return transform;
    } else {
        return inputTransform;
    }
}
Also used : RowData(org.apache.flink.table.data.RowData) TransformationMetadata(org.apache.flink.table.planner.plan.nodes.exec.utils.TransformationMetadata) StreamRecordTimestampInserter(org.apache.flink.table.runtime.operators.sink.StreamRecordTimestampInserter) LogicalType(org.apache.flink.table.types.logical.LogicalType) SortSpec(org.apache.flink.table.planner.plan.nodes.exec.spec.SortSpec)

Aggregations

RowData (org.apache.flink.table.data.RowData)1 SortSpec (org.apache.flink.table.planner.plan.nodes.exec.spec.SortSpec)1 TransformationMetadata (org.apache.flink.table.planner.plan.nodes.exec.utils.TransformationMetadata)1 StreamRecordTimestampInserter (org.apache.flink.table.runtime.operators.sink.StreamRecordTimestampInserter)1 LogicalType (org.apache.flink.table.types.logical.LogicalType)1