luoyuxia commented on code in PR #23046: URL: https://github.com/apache/flink/pull/23046#discussion_r1273309793
########## docs/content.zh/docs/dev/table/sql/truncate.md: ########## @@ -0,0 +1,101 @@ +--- +title: "TRUNCATE TABLE 语句" +weight: 8 +type: docs +aliases: +- /zh/dev/table/sql/truncate.html +--- +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + +<a name="truncate-statements"></a> + +# TRUNCATE TABLE 语句 + +DESCRIBE 语句用于删除表中的全部数据,但不会删除表本身。TRUNCATE TABLE 语句目前仅支持使用在Batch模式。 Review Comment: ```suggestion TRUNCATE TABLE 语句用于删除表中的全部数据,但不会删除表本身。TRUNCATE TABLE 语句目前仅支持在Batch 模式下使用。 ``` ########## docs/content/docs/dev/table/sql/truncate.md: ########## @@ -0,0 +1,97 @@ +--- +title: "TRUNCATE TABLE Statement" +weight: 8 +type: docs +aliases: +- /dev/table/sql/truncate.html +--- +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + +# TRUNCATE TABLE Statement + +TRUNCATE TABLE statement are used to delete all rows from a table without dropping the table itself. +TRUNCATE TABLE statement is only supported in batch execution mode now. Review Comment: dito ########## docs/content/docs/dev/table/sql/truncate.md: ########## @@ -0,0 +1,97 @@ +--- +title: "TRUNCATE TABLE Statement" +weight: 8 +type: docs +aliases: +- /dev/table/sql/truncate.html +--- +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + +# TRUNCATE TABLE Statement + +TRUNCATE TABLE statement are used to delete all rows from a table without dropping the table itself. +TRUNCATE TABLE statement is only supported in batch execution mode now. + + +## Run a TRUNCATE TABLE statement + +{{< tabs "truncate" >}} +{{< tab "Java" >}} +TRUNCATE TABLE statement can be executed with the `executeSql()` method of the `TableEnvironment`. The `executeSql()` method returns nothing for a successful TRUNCATE TABLE operation, otherwise will throw an exception. Review Comment: Actually, it doesn't return nothing. It returns `TABLE_RESULT_OK`. If we can't describe what is returned precisely , I'd like to not to mention it. ########## docs/content/docs/dev/table/sql/truncate.md: ########## @@ -0,0 +1,97 @@ +--- +title: "TRUNCATE TABLE Statement" +weight: 8 +type: docs +aliases: +- /dev/table/sql/truncate.html +--- +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + +# TRUNCATE TABLE Statement + +TRUNCATE TABLE statement are used to delete all rows from a table without dropping the table itself. +TRUNCATE TABLE statement is only supported in batch execution mode now. + + +## Run a TRUNCATE TABLE statement + +{{< tabs "truncate" >}} +{{< tab "Java" >}} +TRUNCATE TABLE statement can be executed with the `executeSql()` method of the `TableEnvironment`. The `executeSql()` method returns nothing for a successful TRUNCATE TABLE operation, otherwise will throw an exception. + +The following examples show how to run a TRUNCATE TABLE statement in `TableEnvironment`. +{{< /tab >}} +{{< tab "SQL CLI" >}} + +TRUNCATE TABLE statement can be executed in [SQL CLI]({{< ref "docs/dev/table/sqlClient" >}}). + +The following examples show how to run a TRUNCATE TABLE statement in SQL CLI. + +{{< /tab >}} +{{< /tabs >}} + +{{< tabs "a5de1760-e363-4b8d-9d6f-0bacb35b9dcf" >}} +{{< tab "Java" >}} +```java +TableEnvironment tableEnv = TableEnvironment.create(...); + +// register a table named "Orders" +tableEnv.executeSql( + "CREATE TABLE Orders (" + + " `user` BIGINT NOT NULl comment 'this is primary key'," + + " product VARCHAR(32)," + + " amount INT," + + " ts TIMESTAMP(3) comment 'notice: watermark'," + + " ptime AS PROCTIME() comment 'this is a computed column'," + + " PRIMARY KEY(`user`) NOT ENFORCED," + + " WATERMARK FOR ts AS ts - INTERVAL '1' SECONDS" + + ") with (...)"); + +// print the schema Review Comment: Also, please follow the examples in `delete statement` to make sure we can really delete all rows using truncate table statement. ########## docs/content.zh/docs/dev/table/sql/truncate.md: ########## @@ -0,0 +1,101 @@ +--- +title: "TRUNCATE TABLE 语句" +weight: 8 +type: docs +aliases: +- /zh/dev/table/sql/truncate.html +--- +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + +<a name="truncate-statements"></a> + +# TRUNCATE TABLE 语句 + +DESCRIBE 语句用于删除表中的全部数据,但不会删除表本身。TRUNCATE TABLE 语句目前仅支持使用在Batch模式。 Review Comment: ```suggestion TRUNCATE TABLE 语句用于删除表中的全部数据,但不会删除表本身。TRUNCATE TABLE 语句目前仅支持在Batch 模式下使用。 ``` ########## docs/content.zh/docs/dev/table/sql/truncate.md: ########## @@ -0,0 +1,101 @@ +--- +title: "TRUNCATE TABLE 语句" +weight: 8 +type: docs +aliases: +- /zh/dev/table/sql/truncate.html +--- +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + +<a name="truncate-statements"></a> + +# TRUNCATE TABLE 语句 + +DESCRIBE 语句用于删除表中的全部数据,但不会删除表本身。TRUNCATE TABLE 语句目前仅支持使用在Batch模式。 Review Comment: Please add the attention just like [`DELETE` statement ](https://nightlies.apache.org/flink/flink-docs-master/zh/docs/dev/table/sql/delete/) in FLINK. ``` 注意 目前, DELETE 语句仅支持批模式, 并且要求目标表实现了 [SupportsRowLevelDelete ](https://github.com/apache/flink/blob/master/flink-table/flink-table-common/src/main/java/org/apache/flink/table/connector/sink/abilities/SupportsRowLevelDelete.java)接口。 如果在一个没有实现该接口的表上执行 DELETE,则会抛异常。 ``` ########## docs/content.zh/docs/dev/table/sql/truncate.md: ########## @@ -0,0 +1,101 @@ +--- +title: "TRUNCATE TABLE 语句" +weight: 8 +type: docs +aliases: +- /zh/dev/table/sql/truncate.html +--- +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + +<a name="truncate-statements"></a> + +# TRUNCATE TABLE 语句 + +DESCRIBE 语句用于删除表中的全部数据,但不会删除表本身。TRUNCATE TABLE 语句目前仅支持使用在Batch模式。 Review Comment: Please add the attention just like [`DELETE` statement ](https://nightlies.apache.org/flink/flink-docs-master/zh/docs/dev/table/sql/delete/) in FLINK. ``` 注意 目前, DELETE 语句仅支持批模式, 并且要求目标表实现了 [SupportsRowLevelDelete ](https://github.com/apache/flink/blob/master/flink-table/flink-table-common/src/main/java/org/apache/flink/table/connector/sink/abilities/SupportsRowLevelDelete.java)接口。 如果在一个没有实现该接口的表上执行 DELETE,则会抛异常。 ``` ########## docs/content/docs/dev/table/sql/truncate.md: ########## @@ -0,0 +1,97 @@ +--- +title: "TRUNCATE TABLE Statement" +weight: 8 +type: docs +aliases: +- /dev/table/sql/truncate.html +--- +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + +# TRUNCATE TABLE Statement Review Comment: Change to `TRUNCATE Statements` just like [`ANALYZE Statements`](http://localhost:1313/docs/dev/table/sql/analyze/)? ########## docs/content/docs/dev/table/sql/truncate.md: ########## @@ -0,0 +1,97 @@ +--- +title: "TRUNCATE TABLE Statement" +weight: 8 +type: docs +aliases: +- /dev/table/sql/truncate.html +--- +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + +# TRUNCATE TABLE Statement + +TRUNCATE TABLE statement are used to delete all rows from a table without dropping the table itself. +TRUNCATE TABLE statement is only supported in batch execution mode now. + + +## Run a TRUNCATE TABLE statement + +{{< tabs "truncate" >}} +{{< tab "Java" >}} +TRUNCATE TABLE statement can be executed with the `executeSql()` method of the `TableEnvironment`. The `executeSql()` method returns nothing for a successful TRUNCATE TABLE operation, otherwise will throw an exception. + +The following examples show how to run a TRUNCATE TABLE statement in `TableEnvironment`. +{{< /tab >}} +{{< tab "SQL CLI" >}} + +TRUNCATE TABLE statement can be executed in [SQL CLI]({{< ref "docs/dev/table/sqlClient" >}}). + +The following examples show how to run a TRUNCATE TABLE statement in SQL CLI. + +{{< /tab >}} +{{< /tabs >}} + +{{< tabs "a5de1760-e363-4b8d-9d6f-0bacb35b9dcf" >}} +{{< tab "Java" >}} +```java +TableEnvironment tableEnv = TableEnvironment.create(...); + +// register a table named "Orders" +tableEnv.executeSql( + "CREATE TABLE Orders (" + + " `user` BIGINT NOT NULl comment 'this is primary key'," + + " product VARCHAR(32)," + + " amount INT," + + " ts TIMESTAMP(3) comment 'notice: watermark'," + + " ptime AS PROCTIME() comment 'this is a computed column'," + + " PRIMARY KEY(`user`) NOT ENFORCED," + + " WATERMARK FOR ts AS ts - INTERVAL '1' SECONDS" + + ") with (...)"); + +// print the schema Review Comment: why `// print the schema`? ########## docs/content/docs/dev/table/sql/truncate.md: ########## @@ -0,0 +1,97 @@ +--- +title: "TRUNCATE TABLE Statement" +weight: 8 +type: docs +aliases: +- /dev/table/sql/truncate.html +--- +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + +# TRUNCATE TABLE Statement + +TRUNCATE TABLE statement are used to delete all rows from a table without dropping the table itself. +TRUNCATE TABLE statement is only supported in batch execution mode now. + + +## Run a TRUNCATE TABLE statement + +{{< tabs "truncate" >}} +{{< tab "Java" >}} Review Comment: Why miss `Scala`/`Python` example? -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
