问题描述
是否可以以与CSV相同的方式在Table API和/或DataStream API中使用JSON文件接收器?
谢谢!
my_sink_ddl = f"""
create table mySink (
id STRING,dummy_item STRING
) with (
'connector.type' = 'filesystem','format.type' = 'json','connector.path' = 'output.json'
)
"""
TableException: findAndCreateTableSink Failed.
解决方法
是的,根据Jira FLINK-17286 Integrate json to file system connector和相应的拉取请求[FLINK-17286][connectors / filesystem]Integrate json to file system connector #12010,可以从Flink 1.11
开始。在Flink 1.11
之前,我认为它不受支持。
您需要使用以下配置:
... with (
'connector' = 'filesystem','format' = 'json','path' = 'output_json' -- This must be a directory
)
加上以下环境定义:
t_env = BatchTableEnvironment.create( environment_settings=EnvironmentSettings.new_instance().in_batch_mode().use_blink_planner().build())