healchow commented on code in PR #21726: URL: https://github.com/apache/flink/pull/21726#discussion_r1081454537
########## docs/content.zh/docs/dev/table/sql/queries/overview.md: ########## @@ -155,110 +158,116 @@ sink_descriptor = TableDescriptor.for_connector("filesystem") t_env.create_temporary_table("RubberOrders", sink_descriptor) -# run an INSERT SQL on the Table and emit the result to the TableSink +# 在表上执行一个 INSERT SQL ,SQL结果写入到TableSink table_env \ .execute_sql("INSERT INTO RubberOrders SELECT product, amount FROM Orders WHERE product LIKE '%Rubber%'") ``` + {{< /tab >}} {{< /tabs >}} {{< top >}} -## Execute a Query +## 执行查询 +通过`TableEnvironment.executeSql()`方法可以执行`SELECT`或`VALUES`语句,并把结果收集到本地.它将`SELECT`语句(或`VALUES`语句)的结果作为`TableResult`返回.和`SELECT`语句相似,`Table.execute()`方法可以执行`Table`对象,并把结果收集到本地客户端. +`TableResult.collect()`方法返回一个可关闭的行迭代器(row iterator).除非所有结果数据都被收集完成了,否则`SELECT`作业不会停止,所以应该积极使用`CloseableIterator#close()`方法关闭作业,以防止资源泄露. `TableResult.print()`可以打印`SELECT`的结果到客户端的控制台中.`TableResult`上的结果数据只能被访问一次.因此`collect()`和`print()`只能二选一. -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. -`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. Thus, `collect()` and `print()` must not be called after each other. +`TableResult.collect()` 和 `TableResult.print()`在不同的checkpointing设置下有一些差异.(流式作业开启checkpointing, 参见 \[checkpointing 设置]\({{< ref "docs/deployment/config" >}}#checkpointing)). -`TableResult.collect()` and `TableResult.print()` have slightly different behaviors under different checkpointing settings (to enable checkpointing for a streaming job, see [checkpointing config]({{< ref "docs/deployment/config" >}}#checkpointing)). -* For batch jobs or streaming jobs without checkpointing, `TableResult.collect()` and `TableResult.print()` have neither exactly-once nor at-least-once guarantee. Query results are immediately accessible by the clients once they're produced, but exceptions will be thrown when the job fails and restarts. -* For streaming jobs with exactly-once checkpointing, `TableResult.collect()` and `TableResult.print()` guarantee an end-to-end exactly-once record delivery. A result will be accessible by clients only after its corresponding checkpoint completes. -* For streaming jobs with at-least-once checkpointing, `TableResult.collect()` and `TableResult.print()` guarantee an end-to-end at-least-once record delivery. Query results are immediately accessible by the clients once they're produced, but it is possible for the same result to be delivered multiple times. +* 对于没有checkpointing的批式或流式作业, `TableResult.collect()` 和 `TableResult.print()` 既不保证精确一次(exactly-once)也不保证至少一次(at-least-once) .查询结果一旦产生,客户端可以立即访问,但是,作业失败或重启将抛出异常. Review Comment: 建议使用中文标点,并且在中文与英文之间添加一个空格,以提高阅读体验。比如: ``` * 对于没有 checkpointing 的批式或流式作业,`TableResult.collect()` 和 `TableResult.print()` 既不保证精确一次(exactly-once)也不保证至少一次(at-least-once)。查询结果一旦产生,客户端可以立即访问,但是作业失败或重启时将会抛出异常。 ``` -- 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. To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org