[ https://issues.apache.org/jira/browse/FLINK-6746?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16031302#comment-16031302 ]
ASF GitHub Bot commented on FLINK-6746: --------------------------------------- Github user alpinegizmo commented on a diff in the pull request: https://github.com/apache/flink/pull/4012#discussion_r119367038 --- Diff: docs/dev/table/common.md --- @@ -98,374 +89,767 @@ env.execute("Your Query") </div> </div> +**Note:** Table API and SQL queries can be easily integrated with and embedded into DataStream or DataSet programs. Have a look a the [Integration with DataStream and DataSet API](#integration-with-datastream-and-dataset-api) section to learn how DataStreams and DataSets can be converted into Tables and vice versa. + {% top %} Create a TableEnvironment ------------------------- -A `Table` is always bound to a specific `TableEnvironment`. It is not possible to combine Tables of different TableEnvironments. +The `TableEnvironment` is a central concept of the Table API and SQL integration. It is responsible for: +* Registering a `Table` in the internal catalog +* Registering an external catalog +* Executing SQL queries +* Registering a user-defined (scalar, table, or aggregation) function +* Converting a `DataStream` or `DataSet` into a `Table` +* Holding a reference to an `ExecutionEnvironment` or `StreamExecutionEnvironment` + +A `Table` is always bound to a specific `TableEnvironment`. It is not process tables of different TableEnvironments in the same query, e.g., to join or union them. + +A `TableEnvironment` is created by calling the static `TableEnvironment.getTableEnvironment()` method with a `StreamExecutionEnvironment` or an `ExecutionEnvironment` and an optional `TableConfig`. The `TableConfig` can be used to configure the `TableEnvironment` or to customize the query optimization and translation process (see [Query Optimization](#query-optimization)). -**TODO: Extend** +<div class="codetabs" markdown="1"> +<div data-lang="java" markdown="1"> +{% highlight java %} +// *************** +// STREAMING QUERY +// *************** +StreamExecutionEnvironment sEnv = StreamExecutionEnvironment.getExecutionEnvironment(); +// Create a TableEnvironment for streaming queries +StreamTableEnvironment sTableEnv = TableEnvironment.getTableEnvironment(sEnv); + +// *********** +// BATCH QUERY +// *********** +ExecutionEnvironment bEnv = ExecutionEnvironment.getExecutionEnvironment(); +// Create a TableEnvironment for batch queries +BatchTableEnvironment bTableEnv = TableEnvironment.getTableEnvironment(bEnv); +{% endhighlight %} +</div> + +<div data-lang="scala" markdown="1"> +{% highlight scala %} +// *************** +// STREAMING QUERY +// *************** +val sEnv = StreamExecutionEnvironment.getExecutionEnvironment +// Create a TableEnvironment for streaming queries +val sTableEnv = TableEnvironment.getTableEnvironment(sEnv) + +// *********** +// BATCH QUERY +// *********** +val bEnv = ExecutionEnvironment.getExecutionEnvironment +// Create a TableEnvironment for batch queries +val bTableEnv = TableEnvironment.getTableEnvironment(bEnv) +{% endhighlight %} +</div> +</div> {% top %} Register a Table in the Catalog ------------------------------- -`TableEnvironment`s have an internal table catalog to which tables can be registered with a unique name. After registration, a table can be accessed from the `TableEnvironment` by its name. +A `TableEnvironment` has an internal catalog to register tables by name. Table API or SQL queries can access tables, which are registered in the catalog by referencing them with their name. --- End diff -- A `TableEnvironment` has an internal catalog of tables, organized by table name. Table API or SQL queries can access tables which have been registered in the catalog, by referencing them by name. > 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)