// 1. old planner 通过流环境来 创建Table流处理环境
val fsSettings = EnvironmentSettings.newInstance().useOldPlanner().inStreamingMode().build()
val fsEnv = StreamExecutionEnvironment.getExecutionEnvironment
val fsTableEnv = StreamTableEnvironment.create(fsEnv, fsSettings)
// val fsTableEnv = TableEnvironment.create(fsSettings) 第二种方式 根据settings 直接创建环境
// 2. old planner 创建批处理环境
val fbEnv = ExecutionEnvironment.getExecutionEnvironment
val fbTableEnv = BatchTableEnvironment.create(fbEnv)
//3. Blink planner 方式创建表的流处理环境
val bsSettings = EnvironmentSettings.newInstance().useBlinkPlanner().inStreamingMode().build()
val bsEnv = StreamExecutionEnvironment.getExecutionEnvironment
val bsTableEnv = StreamTableEnvironment.create(bsEnv, bsSettings)
// val bsTableEnv = TableEnvironment.create(bsSettings) // 第二种方式
//4 . Blink planner 方式创建表的批处理环境
val bbSettings = EnvironmentSettings.newInstance().useBlinkPlanner().inBatchMode().build()
val bbTableEnv = TableEnvironment.create(bbSettings)
// 总结: 在Blink planner中,只需要实现EnvironmentSettings设置即可区分批处理与流处理环境 inStreamingMode/inBatchMode,统一API
Flink Table API创建环境的方式
最新推荐文章于 2024-03-20 14:52:09 发布