[
https://issues.apache.org/jira/browse/FLINK-6746?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16029323#comment-16029323
]
ASF GitHub Bot commented on FLINK-6746:
---------------------------------------
Github user sunjincheng121 commented on a diff in the pull request:
https://github.com/apache/flink/pull/4012#discussion_r119069314
--- Diff: docs/dev/table/common.md ---
@@ -22,43 +22,38 @@ specific language governing permissions and limitations
under the License.
-->
-The Table API and SQL are integrated API and share many concepts and much
of their API.
-
-**TODO: Extend**
+The Table API and SQL are integrated in a joint API. The central concept
of this API is a `Table` which serves as input and output of queries. This
document shows the common structure of programs with Table API and SQL queries,
how to register a `Table`, how to query a `Table`, and how to emit a `Table`.
* This will be replaced by the TOC
{:toc}
Structure of Table API and SQL Programs
---------------------------------------
-All Table API and SQL programs for batch and streaming have the same
structure.
+All Table API and SQL programs for batch and streaming inputs follow the
same steps. The following code example shows the common structure of Table API
and SQL programs.
<div class="codetabs" markdown="1">
<div data-lang="java" markdown="1">
{% highlight java %}
+// For batch programs use ExecutionEnvironment instead of
StreamExecutionEnvironment
StreamExecutionEnvironment env =
StreamExecutionEnvironment.getExecutionEnvironment();
// Create a TableEnvironment
+// For batch programs use BatchTableEnvironment instead of
StreamTableEnvironment
StreamTableEnvironment tableEnv =
TableEnvironment.getTableEnvironment(env);
// Register a Table
-tableEnv.registerTable("yourTable", ...) // or
-tableEnv.registerTableSource("yourTableSrc", ...); // or
-tableEnv.registerDataStream("yourTableStream", ...); // or
-tableEnv.registerDataSet("yourTableSet", ...); // or
-tableEnv.registerExternalCatalog("yourCatalog", ...);
-
-// Create a table from a Table API query
-Table tapiResult = tableEnv.scan("yourTableSrc").select(...);
-// Or create a table from a SQL query
-Table sqlResult = tableEnv.sql("SELECT ... FROM yourTableSrc ... ");
-
-// Emit a Table to a TableSink / DataStream / DataSet
-resultTable.writeToSink(...); // or
-resultTable.toAppendStream(...); // or
-resultTable.toRetractStream(...); // or
-resultTable.toDataSet(...);
+tableEnv.registerTable("table1", ...) // or
+tableEnv.registerTableSource("table2", ...); // or
+tableEnv.registerExternalCatalog("extCat", ...);
+
+// Create a Table from a Table API query
+Table tapiResult = tableEnv.scan("table1").select(...);
+// Create a Table from a SQL query
+Table sqlResult = tableEnv.sql("SELECT ... FROM table2 ... ");
+
+// Emit a Table to a TableSink
+resultTable.writeToSink(...);
--- End diff --
Do we need unified naming `sqlResult` `tapiResult` -> `resultTable`?
> Table API / SQL Docs: Common Page
> ---------------------------------
>
> Key: FLINK-6746
> URL: https://issues.apache.org/jira/browse/FLINK-6746
> Project: Flink
> Issue Type: Sub-task
> Components: Documentation, Table API & SQL
> Affects Versions: 1.3.0
> Reporter: Fabian Hueske
> Assignee: Fabian Hueske
>
> Update and refine ./docs/dev/table/common.md in feature branch
> https://github.com/apache/flink/tree/tableDocs
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)