0.Maven 设置
1.代码
val env = StreamExecutionEnvironment.getExecutionEnvironment
val tableEnv = TableEnvironment.getTableEnvironment(env)
// input tables and output tables--// register a Table
tableEnv.registerTable("table1", ...)
// create a Table from a Table API query
val tapiResult = tableEnv.scan("table1").select(...)
// Create a Table from a SQL query
val sqlResult = tableEnv.sqlQuery("SELECT ... FROM table2 ...")
// emit a Table API result Table to a TableSink, same for SQL result
// create a TableSink
val sink: TableSink = new CsvTableSink("/path/to/file", fieldDelim = "|")
tapiResult.writeToSink(sink)
2.批量计算
val bEnv = ExecutionEnvironment.getExecutionEnvironment
val bTableEnv = TableEnvironment.getTableEnvironment(bEnv)
3.说明:两种层级的API的交互
A DataStream or DataSet can be registered in a TableEnvironment as a Table
Convert a DataStream or DataSet into a Table
Convert a Table into a DataStream or DataSet
接口类型三:SQL
QL Client -- Flink’s Table & SQL API makes it possible to work with queries written in the SQL language
支持两种方式
supports two modes for maintaining and visualizing results. 命令:SET execution.result-mode=
table mode 表模式
changelog mode 模式