Github user alpinegizmo commented on a diff in the pull request:
https://github.com/apache/flink/pull/4012#discussion_r119367358
--- 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.
-*Note: `DataSet`s or `DataStream`s can be directly converted into `Table`s
without registering them in the `TableEnvironment`. See [Create a Table from a
DataStream or DataSet](#tbd) for details.
+A `TableEnvironment` allows to register a table from various sources:
--- End diff --
A `TableEnvironment` allows you to register a table from various sources:
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---