godfreyhe commented on code in PR #20506:
URL: https://github.com/apache/flink/pull/20506#discussion_r946588680


##########
docs/content/docs/dev/table/sql/analyze.md:
##########
@@ -0,0 +1,363 @@
+---
+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.

Review Comment:
   `ANALYZE TABLE` statements are triggered manually instead of automatically



##########
docs/content/docs/dev/table/sql/analyze.md:
##########
@@ -0,0 +1,363 @@
+---
+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 "Store"
+tableEnv.executeSql(
+        "CREATE TABLE Store (" +
+        " `id` BIGINT NOT NULl," +
+        " location VARCHAR(32)," +
+        " owner VARCHAR(32)" +
+        ") with (...)");
+
+// register a partition table named "Orders"
+tableEnv.executeSql(
+        "CREATE TABLE Orders (" +
+        " `id` BIGINT NOT NULl," +
+        " product VARCHAR(32)," +
+        " amount INT," +
+        " `sold_year` BIGINT", +
+        " `sold_month` BIGINT", +
+        ") PARTITIONED BY (`sold_year`, `sold_month`) "
+        ") with (...)");
+
+// Non-partition table, collect row count.
+tableEnv.executeSql("ANALYZE TABLE Store COMPUTE STATISTICS");
+
+// Non-partition table, collect row count and statistics for all columns.
+tableEnv.executeSql("ANALYZE TABLE Store COMPUTE STATISTICS FOR ALL COLUMNS");
+
+// Non-partition table, collect row count and statistics for column `location`.
+tableEnv.executeSql("ANALYZE TABLE Store COMPUTE STATISTICS FOR 
COLUMNS(location)");
+
+
+// Suppose table "Orders" has 4 partitions with specs:
+// Partition1 : (sold_year='2022', sold_month='8')
+// Partition2 : (sold_year='2022', sold_month='9')
+// Partition3 : (sold_year='2021', sold_month='8')
+// Partition3 : (sold_year='2021', sold_month='9')
+
+
+// Partition table, collect row count for Partition1.
+tableEnv.executeSql("ANALYZE TABLE Orders PARTITION (sold_year='2022', 
sold_month='8') COMPUTE STATISTICS");
+
+// Partition table, collect row count for Partition1 and Partition2.
+tableEnv.executeSql("ANALYZE TABLE Orders PARTITION (sold_year='2022', 
sold_month) COMPUTE STATISTICS");
+
+// Partition table, collect row count for all partitions.
+tableEnv.executeSql("ANALYZE TABLE Orders COMPUTE STATISTICS");
+
+// Partition table, collect row count and statistics for all columns on 
partition1.
+tableEnv.executeSql("ANALYZE TABLE Orders PARTITION (sold_year='2022', 
sold_month='8') COMPUTE STATISTICS FOR ALL COLUMNS");
+
+// Partition table, collect row count and statistics for all columns on 
partition1 and partition2.
+tableEnv.executeSql("ANALYZE TABLE Orders PARTITION (sold_year='2022', 
sold_month) COMPUTE STATISTICS FOR ALL COLUMNS");
+
+// Partition table, collect row count and statistics for all columns on all 
partitions.
+tableEnv.executeSql("ANALYZE TABLE Orders COMPUTE STATISTICS FOR ALL COLUMNS");
+
+// Partition table, collect row count and statistics for column `amount` on 
partition1.
+tableEnv.executeSql("ANALYZE TABLE Orders PARTITION (sold_year='2022', 
sold_month='8') COMPUTE STATISTICS FOR COLUMNS(amount)");
+
+// Partition table, collect row count and statistics for `amount` and 
`product` on partition1 and partition2.
+tableEnv.executeSql("ANALYZE TABLE Orders PARTITION (sold_year='2022', 
sold_month) COMPUTE STATISTICS FOR COLUMNS(amount, product)");
+
+// Partition table, collect row count and statistics for column `amount` and 
`product` on all partitions.
+tableEnv.executeSql("ANALYZE TABLE Orders COMPUTE STATISTICS FOR 
COLUMNS(amount, product)");
+```
+{{< /tab >}}
+{{< tab "Scala" >}}
+```scala
+val tableEnv = TableEnvironment.create(...)
+
+// register a non-partition table named "Store"
+tableEnv.executeSql(
+  "CREATE TABLE Store (" +
+          " `id` BIGINT NOT NULl," +
+          " location VARCHAR(32)," +
+          " owner VARCHAR(32)" +
+          ") with (...)");
+
+// register a partition table named "Orders"
+tableEnv.executeSql(
+  "CREATE TABLE Orders (" +
+          " `id` BIGINT NOT NULl," +
+          " product VARCHAR(32)," +
+          " amount INT," +
+          " `sold_year` BIGINT", +
+          " `sold_month` BIGINT", +
+          ") PARTITIONED BY (`sold_year`, `sold_month`) "
+") with (...)");
+
+// Non-partition table, collect row count.
+tableEnv.executeSql("ANALYZE TABLE Store COMPUTE STATISTICS");
+
+// Non-partition table, collect row count and statistics for all columns.
+tableEnv.executeSql("ANALYZE TABLE Store COMPUTE STATISTICS FOR ALL COLUMNS");
+
+// Non-partition table, collect row count and statistics for column `location`.
+tableEnv.executeSql("ANALYZE TABLE Store COMPUTE STATISTICS FOR 
COLUMNS(location)");
+
+
+// Suppose table "Orders" has 4 partitions with specs:
+// Partition1 : (sold_year='2022', sold_month='8')
+// Partition2 : (sold_year='2022', sold_month='9')
+// Partition3 : (sold_year='2021', sold_month='8')
+// Partition3 : (sold_year='2021', sold_month='9')
+
+
+// Partition table, collect row count for Partition1.
+tableEnv.executeSql("ANALYZE TABLE Orders PARTITION (sold_year='2022', 
sold_month='8') COMPUTE STATISTICS");
+
+// Partition table, collect row count for Partition1 and Partition2.
+tableEnv.executeSql("ANALYZE TABLE Orders PARTITION (sold_year='2022', 
sold_month) COMPUTE STATISTICS");
+
+// Partition table, collect row count for all partitions.
+tableEnv.executeSql("ANALYZE TABLE Orders COMPUTE STATISTICS");
+
+// Partition table, collect row count and statistics for all columns on 
partition1.
+tableEnv.executeSql("ANALYZE TABLE Orders PARTITION (sold_year='2022', 
sold_month='8') COMPUTE STATISTICS FOR ALL COLUMNS");
+
+// Partition table, collect row count and statistics for all columns on 
partition1 and partition2.
+tableEnv.executeSql("ANALYZE TABLE Orders PARTITION (sold_year='2022', 
sold_month) COMPUTE STATISTICS FOR ALL COLUMNS");
+
+// Partition table, collect row count and statistics for all columns on all 
partitions.
+tableEnv.executeSql("ANALYZE TABLE Orders COMPUTE STATISTICS FOR ALL COLUMNS");
+
+// Partition table, collect row count and statistics for column `amount` on 
partition1.
+tableEnv.executeSql("ANALYZE TABLE Orders PARTITION (sold_year='2022', 
sold_month='8') COMPUTE STATISTICS FOR COLUMNS(amount)");
+
+// Partition table, collect row count and statistics for `amount` and 
`product` on partition1 and partition2.
+tableEnv.executeSql("ANALYZE TABLE Orders PARTITION (sold_year='2022', 
sold_month) COMPUTE STATISTICS FOR COLUMNS(amount, product)");
+
+// Partition table, collect row count and statistics for column `amount` and 
`product` on all partitions.
+tableEnv.executeSql("ANALYZE TABLE Orders COMPUTE STATISTICS FOR 
COLUMNS(amount, product)");
+```
+{{< /tab >}}
+{{< tab "Python" >}}
+```python
+table_env = TableEnvironment.create(...)
+
+# register a non-partition table named "Store"
+table_env.execute_sql(
+  "CREATE TABLE Store (" +
+          " `id` BIGINT NOT NULl," +
+          " location VARCHAR(32)," +
+          " owner VARCHAR(32)" +
+          ") with (...)");
+
+# register a partition table named "Orders"
+table_env.execute_sql(
+  "CREATE TABLE Orders (" +
+          " `id` BIGINT NOT NULl," +
+          " product VARCHAR(32)," +
+          " amount INT," +
+          " `sold_year` BIGINT", +
+          " `sold_month` BIGINT", +
+          ") PARTITIONED BY (`sold_year`, `sold_month`) "
+") with (...)");
+
+# Non-partition table, collect row count.
+table_env.execute_sql("ANALYZE TABLE Store COMPUTE STATISTICS");
+
+# Non-partition table, collect row count and statistics for all columns.
+table_env.execute_sql("ANALYZE TABLE Store COMPUTE STATISTICS FOR ALL 
COLUMNS");
+
+# Non-partition table, collect row count and statistics for column `location`.
+table_env.execute_sql("ANALYZE TABLE Store COMPUTE STATISTICS FOR 
COLUMNS(location)");
+
+
+# Suppose table "Orders" has 4 partitions with specs:
+# Partition1 : (sold_year='2022', sold_month='8')
+# Partition2 : (sold_year='2022', sold_month='9')
+# Partition3 : (sold_year='2021', sold_month='8')
+# Partition3 : (sold_year='2021', sold_month='9')
+
+
+# Partition table, collect row count for Partition1.
+table_env.execute_sql("ANALYZE TABLE Orders PARTITION (sold_year='2022', 
sold_month='8') COMPUTE STATISTICS");
+
+# Partition table, collect row count for Partition1 and Partition2.
+table_env.execute_sql("ANALYZE TABLE Orders PARTITION (sold_year='2022', 
sold_month) COMPUTE STATISTICS");
+
+# Partition table, collect row count for all partitions.
+table_env.execute_sql("ANALYZE TABLE Orders COMPUTE STATISTICS");
+
+# Partition table, collect row count and statistics for all columns on 
partition1.
+table_env.execute_sql("ANALYZE TABLE Orders PARTITION (sold_year='2022', 
sold_month='8') COMPUTE STATISTICS FOR ALL COLUMNS");
+
+# Partition table, collect row count and statistics for all columns on 
partition1 and partition2.
+table_env.execute_sql("ANALYZE TABLE Orders PARTITION (sold_year='2022', 
sold_month) COMPUTE STATISTICS FOR ALL COLUMNS");
+
+# Partition table, collect row count and statistics for all columns on all 
partitions.
+table_env.execute_sql("ANALYZE TABLE Orders COMPUTE STATISTICS FOR ALL 
COLUMNS");
+
+# Partition table, collect row count and statistics for column `amount` on 
partition1.
+table_env.execute_sql("ANALYZE TABLE Orders PARTITION (sold_year='2022', 
sold_month='8') COMPUTE STATISTICS FOR COLUMNS(amount)");
+
+# Partition table, collect row count and statistics for `amount` and `product` 
on partition1 and partition2.
+table_env.execute_sql("ANALYZE TABLE Orders PARTITION (sold_year='2022', 
sold_month) COMPUTE STATISTICS FOR COLUMNS(amount, product)");
+
+# Partition table, collect row count and statistics for column `amount` and 
`product` on all partitions.
+table_env.execute_sql("ANALYZE TABLE Orders COMPUTE STATISTICS FOR 
COLUMNS(amount, product)");
+```
+{{< /tab >}}
+{{< tab "SQL CLI" >}}
+```sql
+Flink SQL> CREATE TABLE Store (
+> `id` BIGINT NOT NULl,
+> location VARCHAR(32),
+> owner VARCHAR(32)
+> ) with (
+> ...
+> );
+[INFO] Table has been created.
+
+Flink SQL> CREATE TABLE Orders (
+> `id` BIGINT NOT NULl,
+> product VARCHAR(32),
+> amount INT,
+> `sold_year` BIGINT",
+> `sold_month` BIGINT",
+> ) PARTITIONED BY (`sold_year`, `sold_month`)
+> ) with (
+> ...
+> );
+[INFO] Table has been created.
+
+Flink SQL> ANALYZE TABLE Store COMPUTE STATISTICS;
+    
+Flink SQL> ANALYZE TABLE Store COMPUTE STATISTICS FOR ALL COLUMNS;
+
+Flink SQL> ANALYZE TABLE Store COMPUTE STATISTICS FOR COLUMNS(location);
+    
+Flink SQL> ANALYZE TABLE Orders PARTITION (sold_year='2022', sold_month='8') 
COMPUTE STATISTICS;
+
+Flink SQL> ANALYZE TABLE Orders PARTITION (sold_year='2022', sold_month) 
COMPUTE STATISTICS;
+
+Flink SQL> ANALYZE TABLE Orders COMPUTE STATISTICS;
+
+Flink SQL> ANALYZE TABLE Orders PARTITION (sold_year='2022', sold_month='8') 
COMPUTE STATISTICS FOR ALL COLUMNS;
+
+Flink SQL> ANALYZE TABLE Orders PARTITION (sold_year='2022', sold_month) 
COMPUTE STATISTICS FOR ALL COLUMNS;
+    
+Flink SQL> ANALYZE TABLE Orders PARTITION (sold_year='2022', sold_month='8') 
COMPUTE STATISTICS FOR COLUMNS(amount);
+    
+Flink SQL> ANALYZE TABLE Orders PARTITION (sold_year='2022', sold_month) 
COMPUTE STATISTICS FOR COLUMNS(amount, product);
+    
+Flink SQL> ANALYZE TABLE Orders COMPUTE STATISTICS FOR COLUMNS(amount, 
product);
+```
+{{< /tab >}}
+{{< /tabs >}}
+
+
+## Syntax
+
+```sql
+ANALYZE TABLE [catalog_name.][db_name.]table_name [PARTITION(partcol1=val1 [, 
partcol2=val2, ...])] COMPUTE STATISTICS [FOR COLUMNS col1 [, col2, ...] | FOR 
ALL COLUMNS]

Review Comment:
   the syntax should be updated as: `PARTITION (partcol1[=val1] [, 
partcol2[=val2], ...])` see the FLIP doc



##########
docs/content/docs/dev/table/sql/analyze.md:
##########
@@ -0,0 +1,363 @@
+---
+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 "Store"
+tableEnv.executeSql(
+        "CREATE TABLE Store (" +
+        " `id` BIGINT NOT NULl," +
+        " location VARCHAR(32)," +
+        " owner VARCHAR(32)" +
+        ") with (...)");
+
+// register a partition table named "Orders"
+tableEnv.executeSql(
+        "CREATE TABLE Orders (" +
+        " `id` BIGINT NOT NULl," +
+        " product VARCHAR(32)," +
+        " amount INT," +
+        " `sold_year` BIGINT", +
+        " `sold_month` BIGINT", +
+        ") PARTITIONED BY (`sold_year`, `sold_month`) "
+        ") with (...)");
+
+// Non-partition table, collect row count.
+tableEnv.executeSql("ANALYZE TABLE Store COMPUTE STATISTICS");
+
+// Non-partition table, collect row count and statistics for all columns.
+tableEnv.executeSql("ANALYZE TABLE Store COMPUTE STATISTICS FOR ALL COLUMNS");
+
+// Non-partition table, collect row count and statistics for column `location`.
+tableEnv.executeSql("ANALYZE TABLE Store COMPUTE STATISTICS FOR 
COLUMNS(location)");
+
+
+// Suppose table "Orders" has 4 partitions with specs:
+// Partition1 : (sold_year='2022', sold_month='8')
+// Partition2 : (sold_year='2022', sold_month='9')
+// Partition3 : (sold_year='2021', sold_month='8')
+// Partition3 : (sold_year='2021', sold_month='9')
+
+
+// Partition table, collect row count for Partition1.
+tableEnv.executeSql("ANALYZE TABLE Orders PARTITION (sold_year='2022', 
sold_month='8') COMPUTE STATISTICS");
+
+// Partition table, collect row count for Partition1 and Partition2.
+tableEnv.executeSql("ANALYZE TABLE Orders PARTITION (sold_year='2022', 
sold_month) COMPUTE STATISTICS");
+
+// Partition table, collect row count for all partitions.
+tableEnv.executeSql("ANALYZE TABLE Orders COMPUTE STATISTICS");
+
+// Partition table, collect row count and statistics for all columns on 
partition1.
+tableEnv.executeSql("ANALYZE TABLE Orders PARTITION (sold_year='2022', 
sold_month='8') COMPUTE STATISTICS FOR ALL COLUMNS");
+
+// Partition table, collect row count and statistics for all columns on 
partition1 and partition2.
+tableEnv.executeSql("ANALYZE TABLE Orders PARTITION (sold_year='2022', 
sold_month) COMPUTE STATISTICS FOR ALL COLUMNS");
+
+// Partition table, collect row count and statistics for all columns on all 
partitions.
+tableEnv.executeSql("ANALYZE TABLE Orders COMPUTE STATISTICS FOR ALL COLUMNS");
+
+// Partition table, collect row count and statistics for column `amount` on 
partition1.
+tableEnv.executeSql("ANALYZE TABLE Orders PARTITION (sold_year='2022', 
sold_month='8') COMPUTE STATISTICS FOR COLUMNS(amount)");
+
+// Partition table, collect row count and statistics for `amount` and 
`product` on partition1 and partition2.
+tableEnv.executeSql("ANALYZE TABLE Orders PARTITION (sold_year='2022', 
sold_month) COMPUTE STATISTICS FOR COLUMNS(amount, product)");
+
+// Partition table, collect row count and statistics for column `amount` and 
`product` on all partitions.
+tableEnv.executeSql("ANALYZE TABLE Orders COMPUTE STATISTICS FOR 
COLUMNS(amount, product)");
+```
+{{< /tab >}}
+{{< tab "Scala" >}}
+```scala
+val tableEnv = TableEnvironment.create(...)
+
+// register a non-partition table named "Store"
+tableEnv.executeSql(
+  "CREATE TABLE Store (" +
+          " `id` BIGINT NOT NULl," +
+          " location VARCHAR(32)," +
+          " owner VARCHAR(32)" +
+          ") with (...)");
+
+// register a partition table named "Orders"
+tableEnv.executeSql(
+  "CREATE TABLE Orders (" +
+          " `id` BIGINT NOT NULl," +
+          " product VARCHAR(32)," +
+          " amount INT," +
+          " `sold_year` BIGINT", +
+          " `sold_month` BIGINT", +
+          ") PARTITIONED BY (`sold_year`, `sold_month`) "
+") with (...)");
+
+// Non-partition table, collect row count.
+tableEnv.executeSql("ANALYZE TABLE Store COMPUTE STATISTICS");
+
+// Non-partition table, collect row count and statistics for all columns.
+tableEnv.executeSql("ANALYZE TABLE Store COMPUTE STATISTICS FOR ALL COLUMNS");
+
+// Non-partition table, collect row count and statistics for column `location`.
+tableEnv.executeSql("ANALYZE TABLE Store COMPUTE STATISTICS FOR 
COLUMNS(location)");
+
+
+// Suppose table "Orders" has 4 partitions with specs:
+// Partition1 : (sold_year='2022', sold_month='8')
+// Partition2 : (sold_year='2022', sold_month='9')
+// Partition3 : (sold_year='2021', sold_month='8')
+// Partition3 : (sold_year='2021', sold_month='9')
+
+
+// Partition table, collect row count for Partition1.
+tableEnv.executeSql("ANALYZE TABLE Orders PARTITION (sold_year='2022', 
sold_month='8') COMPUTE STATISTICS");
+
+// Partition table, collect row count for Partition1 and Partition2.
+tableEnv.executeSql("ANALYZE TABLE Orders PARTITION (sold_year='2022', 
sold_month) COMPUTE STATISTICS");
+
+// Partition table, collect row count for all partitions.
+tableEnv.executeSql("ANALYZE TABLE Orders COMPUTE STATISTICS");
+
+// Partition table, collect row count and statistics for all columns on 
partition1.
+tableEnv.executeSql("ANALYZE TABLE Orders PARTITION (sold_year='2022', 
sold_month='8') COMPUTE STATISTICS FOR ALL COLUMNS");
+
+// Partition table, collect row count and statistics for all columns on 
partition1 and partition2.
+tableEnv.executeSql("ANALYZE TABLE Orders PARTITION (sold_year='2022', 
sold_month) COMPUTE STATISTICS FOR ALL COLUMNS");
+
+// Partition table, collect row count and statistics for all columns on all 
partitions.
+tableEnv.executeSql("ANALYZE TABLE Orders COMPUTE STATISTICS FOR ALL COLUMNS");
+
+// Partition table, collect row count and statistics for column `amount` on 
partition1.
+tableEnv.executeSql("ANALYZE TABLE Orders PARTITION (sold_year='2022', 
sold_month='8') COMPUTE STATISTICS FOR COLUMNS(amount)");
+
+// Partition table, collect row count and statistics for `amount` and 
`product` on partition1 and partition2.
+tableEnv.executeSql("ANALYZE TABLE Orders PARTITION (sold_year='2022', 
sold_month) COMPUTE STATISTICS FOR COLUMNS(amount, product)");
+
+// Partition table, collect row count and statistics for column `amount` and 
`product` on all partitions.
+tableEnv.executeSql("ANALYZE TABLE Orders COMPUTE STATISTICS FOR 
COLUMNS(amount, product)");

Review Comment:
   the partition keys should be specific for a partition table.



-- 
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

Reply via email to