Repository: flink Updated Branches: refs/heads/release-1.2 8b7331409 -> d8d9d7603
[hotfix] [docs] Improved Table API docs. Project: http://git-wip-us.apache.org/repos/asf/flink/repo Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/d8d9d760 Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/d8d9d760 Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/d8d9d760 Branch: refs/heads/release-1.2 Commit: d8d9d7603999925054bd35a0d2936c321c647faa Parents: 8b73314 Author: Fabian Hueske <fhue...@apache.org> Authored: Fri Jan 13 16:04:40 2017 +0100 Committer: Fabian Hueske <fhue...@apache.org> Committed: Fri Jan 13 16:07:09 2017 +0100 ---------------------------------------------------------------------- docs/dev/table_api.md | 44 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flink/blob/d8d9d760/docs/dev/table_api.md ---------------------------------------------------------------------- diff --git a/docs/dev/table_api.md b/docs/dev/table_api.md index d443323..81de4b1 100644 --- a/docs/dev/table_api.md +++ b/docs/dev/table_api.md @@ -1416,6 +1416,7 @@ tableReference: tablePrimary: [ TABLE ] [ [ catalogName . ] schemaName . ] tableName + | LATERAL TABLE '(' functionName '(' expression [, expression ]* ')' ')' values: VALUES expression [, expression ]* @@ -4093,9 +4094,12 @@ By default, the Table API supports `null` values. Null handling can be disabled Explaining a Table ---- -The Table API provides a mechanism to describe the graph of operations that leads to the resulting output. This is done through the `TableEnvironment#explain(table)` method. It returns a string describing two graphs: the Abstract Syntax Tree of the relational algebra query and Flink's Execution Plan of the Job. +The Table API provides a mechanism to explain the logical and optimized query plans to compute a `Table`. +This is done through the `TableEnvironment#explain(table)` method. It returns a string describing three plans: -Table `explain` is supported for both `BatchTableEnvironment` and `StreamTableEnvironment`. Currently `StreamTableEnvironment` doesn't support the explanation of the Execution Plan. +1. the Abstract Syntax Tree of the relational query, i.e., the unoptimized logical query plan, +2. the optimized logical query plan, and +3. the physical execution plan. The following code shows an example and the corresponding output: @@ -4110,7 +4114,9 @@ DataStream<Tuple2<Integer, String>> stream2 = env.fromElements(new Tuple2<>(1, " Table table1 = tEnv.fromDataStream(stream1, "count, word"); Table table2 = tEnv.fromDataStream(stream2, "count, word"); -Table table = table1.unionAll(table2); +Table table = table1 + .where("LIKE(word, 'F%')") + .unionAll(table2); String explanation = tEnv.explain(table); System.out.println(explanation); @@ -4124,7 +4130,9 @@ val tEnv = TableEnvironment.getTableEnvironment(env) val table1 = env.fromElements((1, "hello")).toTable(tEnv, 'count, 'word) val table2 = env.fromElements((1, "hello")).toTable(tEnv, 'count, 'word) -val table = table1.unionAll(table2) +val table = table1 + .where('word.like("F%")) + .unionAll(table2) val explanation: String = tEnv.explain(table) println(explanation) @@ -4135,8 +4143,34 @@ println(explanation) {% highlight text %} == Abstract Syntax Tree == LogicalUnion(all=[true]) - LogicalTableScan(table=[[_DataStreamTable_0]]) + LogicalFilter(condition=[LIKE($1, 'F%')]) + LogicalTableScan(table=[[_DataStreamTable_0]]) LogicalTableScan(table=[[_DataStreamTable_1]]) + +== Optimized Logical Plan == +DataStreamUnion(union=[count, word]) + DataStreamCalc(select=[count, word], where=[LIKE(word, 'F%')]) + DataStreamScan(table=[[_DataStreamTable_0]]) + DataStreamScan(table=[[_DataStreamTable_1]]) + +== Physical Execution Plan == +Stage 1 : Data Source + content : collect elements with CollectionInputFormat + +Stage 2 : Data Source + content : collect elements with CollectionInputFormat + + Stage 3 : Operator + content : from: (count, word) + ship_strategy : REBALANCE + + Stage 4 : Operator + content : where: (LIKE(word, 'F%')), select: (count, word) + ship_strategy : FORWARD + + Stage 5 : Operator + content : from: (count, word) + ship_strategy : REBALANCE {% endhighlight %} {% top %}