twalthr commented on a change in pull request #12577:
URL: https://github.com/apache/flink/pull/12577#discussion_r444155326
##########
File path: docs/dev/table/sql/index.md
##########
@@ -28,7 +28,7 @@ This page describes the SQL language supported in Flink,
including Data Definiti
This page lists all the supported statements supported in Flink SQL for now:
-- [SELECT (Queries)](queries.html)
+- [Queries](queries.html)
Review comment:
can we revert this change? Having the keyword directly can help
(`SELECT, VALUES`).
##########
File path: docs/dev/table/sql/create.md
##########
@@ -48,16 +48,16 @@ TableEnvironment tableEnv =
TableEnvironment.create(settings);
// SQL query with a registered table
// register a table named "Orders"
-tableEnv.sqlUpdate("CREATE TABLE Orders (`user` BIGINT, product STRING, amount
INT) WITH (...)");
+tableEnv.executeSql("CREATE TABLE Orders (`user` BIGINT, product STRING,
amount INT) WITH (...)");
// run a SQL query on the Table and retrieve the result as a new Table
Table result = tableEnv.sqlQuery(
"SELECT product, amount FROM Orders WHERE product LIKE '%Rubber%'");
-// SQL update with a registered table
+// Execute insert sql with a registered table
Review comment:
use `SQL` instead of `sql` consistently in docs
##########
File path: docs/dev/table/sql/queries.md
##########
@@ -134,16 +131,100 @@ t_env.connect(FileSystem().path("/path/to/file")))
.field("amount", DataTypes.BIGINT()))
.create_temporary_table("RubberOrders")
-# run a SQL update query on the Table and emit the result to the TableSink
+# run an INSERT SQL on the Table and emit the result to the TableSink
table_env \
- .sql_update("INSERT INTO RubberOrders SELECT product, amount FROM Orders
WHERE product LIKE '%Rubber%'")
+ .execute_sql("INSERT INTO RubberOrders SELECT product, amount FROM Orders
WHERE product LIKE '%Rubber%'")
{% endhighlight %}
</div>
</div>
{% top %}
-## Supported Syntax
+## Execute a Query
+A SELECT statement or a VALUES statement can be executed to collect the
content to local through the `TableEnvironment.executeSql()` method. The method
returns the result of the SELECT statement (or the VALUES statement) as a
`TableResult`. Similar to SELECT statement, a `Table` can also be executed to
collect to content of the table to local through the `Table.execute()` method.
+`TableResult.collect()` method returns a closeable row iterator. The select
job will not be finished unless all result data has been collected. We should
actively close the job to avoid resource leak through the
`CloseableIterator#close()` method.
+We can also print the select result to client console through the
`TableResult.print()` method. The result data in `TableResult` can be accessed
only once, so for a `TableResult` instance, `collect()` method and `print()`
method can't be called both.
Review comment:
```suggestion
We can also print the select result to client console through the
`TableResult.print()` method. The result data in `TableResult` can be accessed
only once. Thus, `collect()` and `print()` must not be called after each other.
```
##########
File path: docs/dev/table/sql/queries.md
##########
@@ -134,16 +131,100 @@ t_env.connect(FileSystem().path("/path/to/file")))
.field("amount", DataTypes.BIGINT()))
.create_temporary_table("RubberOrders")
-# run a SQL update query on the Table and emit the result to the TableSink
+# run an INSERT SQL on the Table and emit the result to the TableSink
table_env \
- .sql_update("INSERT INTO RubberOrders SELECT product, amount FROM Orders
WHERE product LIKE '%Rubber%'")
+ .execute_sql("INSERT INTO RubberOrders SELECT product, amount FROM Orders
WHERE product LIKE '%Rubber%'")
{% endhighlight %}
</div>
</div>
{% top %}
-## Supported Syntax
+## Execute a Query
+A SELECT statement or a VALUES statement can be executed to collect the
content to local through the `TableEnvironment.executeSql()` method. The method
returns the result of the SELECT statement (or the VALUES statement) as a
`TableResult`. Similar to SELECT statement, a `Table` can also be executed to
collect to content of the table to local through the `Table.execute()` method.
Review comment:
```suggestion
A SELECT statement or a VALUES statement can be executed to collect the
content to local through the `TableEnvironment.executeSql()` method. The method
returns the result of the SELECT statement (or the VALUES statement) as a
`TableResult`. Similar to a SELECT statement, a `Table` object can be executed
using the `Table.execute()` method to collect the content of the query to the
local client.
```
##########
File path: docs/dev/table/tableApi.md
##########
@@ -2060,13 +2060,13 @@ result3 = in.order_by("a.asc").offset(10).fetch(5)
<span class="label label-primary">Batch</span> <span class="label
label-primary">Streaming</span>
</td>
<td>
- <p>Similar to the INSERT INTO clause in a SQL query. Performs a
insertion into a registered output table.</p>
+ <p>Similar to the INSERT INTO clause in a SQL query. Performs a
insertion into a registered output table. The executeInsert method will
immediately submit a flink job which execute the insert operation.</p>
Review comment:
```suggestion
<p>Similar to the `INSERT INTO` clause in a SQL query, the method
performs an insertion into a registered output table. The `executeInsert()`
method will immediately submit a Flink job which execute the insert
operation.</p>
```
##########
File path: docs/dev/table/common.md
##########
@@ -849,18 +844,16 @@ Table API and SQL queries are translated into
[DataStream]({{ site.baseurl }}/de
1. Optimization of the logical plan
2. Translation into a DataStream or DataSet program
-For streaming, a Table API or SQL query is translated when:
-
-* `TableEnvironment.execute()` is called. A `Table` (emitted to a `TableSink`
through `Table.insertInto()`) or a SQL update query (specified through
`TableEnvironment.sqlUpdate()`) will be buffered in `TableEnvironment` first.
Each sink will be optimized independently. The execution graph contains
multiple independent sub-DAGs.
-* A `Table` is translated when it is converted into a `DataStream` (see
[Integration with DataStream and DataSet
API](#integration-with-datastream-and-dataset-api)). Once translated, it's a
regular DataStream program and is executed when
`StreamExecutionEnvironment.execute()` is called.
+A Table API or SQL query is translated when:
-For batch, a Table API or SQL query is translated when:
+* `TableEnvironment.executeSql()` is called. This method is used for executing
a given statement, and the sql query is translated immediately once this method
is called.
+* `Table.executeInsert()` is called. This method is used for inserting the
table content to the given sink path, and the Table API is translated
immediately once this method is called.
+* `Table.execute()` is called. This method is used for collecting the table
content to local client, and the Table API is translated immediately once this
method is called.
+* `SatementSet.execute()` is called. A `Table` (emitted to a sink through
`SatementSet.addInsert()`) or an INSERT statement (specified through
`SatementSet.addInsertSql()`) will be buffered in `SatementSet` first. They are
translated once `SatementSet.execute()` is called. Each sink will be optimized
independently. The execution graph contains multiple independent sub-DAGs.
Review comment:
typo for `StatementSet` at multiple locations
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]