Skip to content

Commit 81efb9d

Browse files
committed
Address comments
1 parent a75a30d commit 81efb9d

File tree

4 files changed

+55
-91
lines changed

4 files changed

+55
-91
lines changed

docs/_data/menu-sql.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,8 @@
198198
subitems:
199199
- text: ANALYZE TABLE
200200
url: sql-ref-syntax-aux-analyze-table.html
201+
- text: ANALYZE TABLES
202+
url: sql-ref-syntax-aux-analyze-tables.html
201203
- text: CACHE
202204
url: sql-ref-syntax-aux-cache.html
203205
subitems:

docs/sql-ref-syntax-aux-analyze-table.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ ANALYZE TABLE table_identifier [ partition_spec ]
5050
* If no analyze option is specified, `ANALYZE TABLE` collects the table's number of rows and size in bytes.
5151
* **NOSCAN**
5252

53-
Collects only the table's size in bytes ( which does not require scanning the entire table ).
53+
Collects only the table's size in bytes (which does not require scanning the entire table).
5454
* **FOR COLUMNS col [ , ... ] `|` FOR ALL COLUMNS**
5555

5656
Collects column statistics for each column specified, or alternatively for every column, as well as table statistics.

docs/sql-ref-syntax-aux-analyze-tables.md

Lines changed: 51 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ license: |
2121

2222
### Description
2323

24-
The `ANALYZE TABLES` statement collects statistics about all the tables in a database to be used by the query optimizer to find a better query execution plan.
24+
The `ANALYZE TABLES` statement collects statistics about all the tables in a specified database to be used by the query optimizer to find a better query execution plan.
2525

2626
### Syntax
2727

@@ -37,7 +37,7 @@ ANALYZE TABLES [ { FROM | IN } database_name ] COMPUTE STATISTICS [ NOSCAN ]
3737

3838
* **[ NOSCAN ]**
3939

40-
Collects only the table's size in bytes ( which does not require scanning the entire table ).
40+
Collects only the table's size in bytes (which does not require scanning the entire table).
4141

4242
### Examples
4343

@@ -48,100 +48,61 @@ USE school_db;
4848
CREATE TABLE teachers (name STRING, teacher_id INT);
4949
INSERT INTO teachers VALUES ('Tom', 1), ('Jerry', 2);
5050

51-
CREATE TABLE students (name STRING, student_id INT);
52-
INSERT INTO students VALUES ('Mark', 111111), ('John', 222222);
51+
CREATE TABLE students (name STRING, student_id INT, age SHORT);
52+
INSERT INTO students VALUES ('Mark', 111111, 10), ('John', 222222, 11);
5353

5454
ANALYZE TABLES IN school_db COMPUTE STATISTICS NOSCAN;
5555

56-
SHOW TABLE EXTENDED IN school_db LIKE '*';
57-
+------------+------------+--------------+----------------------------------------------------+
58-
| database | tableName | isTemporary | information |
59-
+------------+------------+--------------+----------------------------------------------------+
60-
|school_db |students |false |Database: school_db
61-
Table: students
62-
Owner: root
63-
Created Time: Wed Dec 09 14:23:25 CST 2020
64-
Last Access: UNKNOWN
65-
Created By: Spark 3.2.0-SNAPSHOT
66-
Type: MANAGED
67-
Provider: hive
68-
Table Properties: [transient_lastDdlTime=1607495032]
69-
Statistics: 24 bytes
70-
Location: file:/opt/spark1/spark/spark-warehouse/school_db.db/students
71-
Serde Library: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
72-
InputFormat: org.apache.hadoop.mapred.TextInputFormat
73-
OutputFormat: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat
74-
Storage Properties: [serialization.format=1]
75-
Partition Provider: Catalog
76-
Schema: root
77-
|-- name: string (nullable = true)
78-
|-- student_id: integer (nullable = true) |
79-
|school_db |teachers |false |Database: school_db
80-
Table: teachers
81-
Owner: root
82-
Created Time: Wed Dec 09 14:24:15 CST 2020
83-
Last Access: UNKNOWN
84-
Created By: Spark 3.2.0-SNAPSHOT
85-
Type: MANAGED
86-
Provider: hive
87-
Table Properties: [transient_lastDdlTime=1607495059]
88-
Statistics: 14 bytes
89-
Location: file:/opt/spark1/spark/spark-warehouse/school_db.db/teachers
90-
Serde Library: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
91-
InputFormat: org.apache.hadoop.mapred.TextInputFormat
92-
OutputFormat: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat
93-
Storage Properties: [serialization.format=1]
94-
Partition Provider: Catalog
95-
Schema: root
96-
|-- name: string (nullable = true)
97-
|-- teacher_id: integer (nullable = true) |
98-
+------------+------------+--------------+----------------------------------------------------+
56+
DESC EXTENDED teachers;
57+
+--------------------+--------------------+-------+
58+
| col_name| data_type|comment|
59+
+--------------------+--------------------+-------+
60+
| name| string| null|
61+
| teacher_id| int| null|
62+
| ...| ...| ...|
63+
| Provider| parquet| |
64+
| Statistics| 1382 bytes| |
65+
| ...| ...| ...|
66+
+--------------------+--------------------+-------+
67+
68+
DESC EXTENDED students;
69+
+--------------------+--------------------+-------+
70+
| col_name| data_type|comment|
71+
+--------------------+--------------------+-------+
72+
| name| string| null|
73+
| student_id| int| null|
74+
| age| smallint| null|
75+
| ...| ...| ...|
76+
| Statistics| 1828 bytes| |
77+
| ...| ...| ...|
78+
+--------------------+--------------------+-------+
9979

10080
ANALYZE TABLES COMPUTE STATISTICS;
10181

102-
SHOW TABLE EXTENDED IN school_db LIKE '*';
103-
+------------+------------+--------------+----------------------------------------------------+
104-
| database | tableName | isTemporary | information |
105-
+------------+------------+--------------+----------------------------------------------------+
106-
|school_db |students |false |Database: school_db
107-
Table: students
108-
Owner: root
109-
Created Time: Wed Dec 09 14:23:25 CST 2020
110-
Last Access: UNKNOWN
111-
Created By: Spark 3.2.0-SNAPSHOT
112-
Type: MANAGED
113-
Provider: hive
114-
Table Properties: [transient_lastDdlTime=1607495311]
115-
Statistics: 24 bytes, 2 rows
116-
Location: file:/opt/spark1/spark/spark-warehouse/school_db.db/students
117-
Serde Library: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
118-
InputFormat: org.apache.hadoop.mapred.TextInputFormat
119-
OutputFormat: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat
120-
Storage Properties: [serialization.format=1]
121-
Partition Provider: Catalog
122-
Schema: root
123-
|-- name: string (nullable = true)
124-
|-- student_id: integer (nullable = true) |
125-
|school_db |teachers |false |Database: school_db
126-
Table: teachers
127-
Owner: root
128-
Created Time: Wed Dec 09 14:24:15 CST 2020
129-
Last Access: UNKNOWN
130-
Created By: Spark 3.2.0-SNAPSHOT
131-
Type: MANAGED
132-
Provider: hive
133-
Table Properties: [transient_lastDdlTime=1607495312]
134-
Statistics: 14 bytes, 2 rows
135-
Location: file:/opt/spark1/spark/spark-warehouse/school_db.db/teachers
136-
Serde Library: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
137-
InputFormat: org.apache.hadoop.mapred.TextInputFormat
138-
OutputFormat: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat
139-
Storage Properties: [serialization.format=1]
140-
Partition Provider: Catalog
141-
Schema: root
142-
|-- name: string (nullable = true)
143-
|-- teacher_id: integer (nullable = true) |
144-
+------------+------------+--------------+----------------------------------------------------+
82+
DESC EXTENDED teachers;
83+
+--------------------+--------------------+-------+
84+
| col_name| data_type|comment|
85+
+--------------------+--------------------+-------+
86+
| name| string| null|
87+
| teacher_id| int| null|
88+
| ...| ...| ...|
89+
| Provider| parquet| |
90+
| Statistics| 1382 bytes, 2 rows| |
91+
| ...| ...| ...|
92+
+--------------------+--------------------+-------+
93+
94+
DESC EXTENDED students;
95+
+--------------------+--------------------+-------+
96+
| col_name| data_type|comment|
97+
+--------------------+--------------------+-------+
98+
| name| string| null|
99+
| student_id| int| null|
100+
| age| smallint| null|
101+
| ...| ...| ...|
102+
| Provider| parquet| |
103+
| Statistics| 1828 bytes, 2 rows| |
104+
| ...| ...| ...|
105+
+--------------------+--------------------+-------+
145106
```
146107

147108
### Related Statements

docs/sql-ref-syntax.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ Spark SQL is Apache Spark's module for working with structured data. The SQL Syn
7777
* [ADD FILE](sql-ref-syntax-aux-resource-mgmt-add-file.html)
7878
* [ADD JAR](sql-ref-syntax-aux-resource-mgmt-add-jar.html)
7979
* [ANALYZE TABLE](sql-ref-syntax-aux-analyze-table.html)
80+
* [ANALYZE TABLES](sql-ref-syntax-aux-analyze-tables.html)
8081
* [CACHE TABLE](sql-ref-syntax-aux-cache-cache-table.html)
8182
* [CLEAR CACHE](sql-ref-syntax-aux-cache-clear-cache.html)
8283
* [DESCRIBE DATABASE](sql-ref-syntax-aux-describe-database.html)

0 commit comments

Comments
 (0)