赞
踩
[root@master pyflink]# cat sink_file.py
import json
import re
import logging
import sys
from collections import Counter
from pyflink.datastream import StreamExecutionEnvironment, RuntimeExecutionMode, WindowFunction
from pyflink.datastream import DataStream, StreamExecutionEnvironment
from pyflink.datastream.functions import RuntimeContext, FlatMapFunction, MapFunction
from pyflink.common.typeinfo import Types
from pyflink.common import ExecutionMode
from pyflink.datastream.connectors import StreamingFileSink
from pyflink.common.serialization import Encoder
env = StreamExecutionEnvironment.get_execution_environment()
env.set_parallelism(1)
ds = env.from_collection(
collection=[(1, 'aaa'), (2, 'bbb')],
type_info=Types.ROW([Types.INT(), Types.STRING()]))
ds.add_sink(StreamingFileSink
.for_row_format('/tmp/output', Encoder.simple_string_encoder())
.build())
env.execute("tutorial_job")
[root@master pyflink]# cat /tmp/output/2024-05-05--09/.part-0-0.inprogress.525d3b8a-c781-4fbb-a5ad-0303c9da32d6
+I[1, aaa]
+I[2, bbb]
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。