swuferhong commented on code in PR #20506: URL: https://github.com/apache/flink/pull/20506#discussion_r945903397
########## docs/content/docs/dev/table/sql/analyze.md: ########## @@ -0,0 +1,364 @@ +--- +title: "ANALYZE TABLE Statements" +weight: 8 +type: docs +aliases: + - /dev/table/sql/analyze.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. +--> + +# ANALYZE TABLE Statements + +- `ANALYZE TABLE` statements are used to collect statistics for existing tables, and write statistics back to catalog. +- Only existing table is supported, and an exception will be thrown if the table is a view or table not exists. +- Currently, `ANALYZE TABLE` only supports in batch mode. +- `ANALYZE TABLE` statements is triggered manually instead of automatically. + + +## Run a ANALYZE TABLE statement + +{{< tabs "analyze table" >}} +{{< tab "Java" >}} +`ANALYZE TABLE` statements can be executed with the `executeSql()` method of the `TableEnvironment`. + +The following examples show how to run a `ANALYZE TABLE` statement in `TableEnvironment`. +{{< /tab >}} +{{< tab "Scala" >}} +`ANALYZE TABLE` statements can be executed with the `executeSql()` method of the `TableEnvironment`. + +The following examples show how to run a `ANALYZE TABLE` statement in `TableEnvironment`. +{{< /tab >}} +{{< tab "Python" >}} + +`ANALYZE TABLE` statements can be executed with the `execute_sql()` method of the `TableEnvironment`. + +The following examples show how to run a `ANALYZE TABLE` statement in `TableEnvironment`. + +{{< /tab >}} +{{< tab "SQL CLI" >}} + +`ANALYZE TABLE` statements can be executed in [SQL CLI]({{< ref "docs/dev/table/sqlClient" >}}). + +The following examples show how to run a `ANALYZE TABLE` statement in SQL CLI. + +{{< /tab >}} +{{< /tabs >}} + +{{< tabs "a5de1760-e363-4b8d-9d6f-0bacb35b9dcf" >}} +{{< tab "Java" >}} +```java +TableEnvironment tableEnv = TableEnvironment.create(...); + +// register a non-partition table named "Orders" +tableEnv.executeSql( + "CREATE TABLE Orders (" + + " `user` BIGINT NOT NULl," + + " product VARCHAR(32)," + + " amount INT," + + " ts TIMESTAMP(3)," + + " ptime AS PROCTIME()" + ") with (...)"); + +// register a partition table named "Store" +tableEnv.executeSql( + "CREATE TABLE Store (" + + " `id` BIGINT NOT NULl," + + " product VARCHAR(32)," + + " amount INT," + + " `date_sk` BIGINT" + + ") PARTITIONED BY (`date_sk`, `id`) " + ") with (...)"); Review Comment: > The `Store` table should be a non-partition table, while the `Orders ` should be a partition table. The partition key could be sold_year, sold_moth, sold_day done! -- 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]
