forked from apache/spark
-
Notifications
You must be signed in to change notification settings - Fork 0
/
describe-table-column.sql
64 lines (36 loc) · 1.49 KB
/
describe-table-column.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
-- Test temp table
CREATE TEMPORARY VIEW desc_col_temp_view (key int COMMENT 'column_comment') USING PARQUET;
DESC desc_col_temp_view key;
DESC EXTENDED desc_col_temp_view key;
DESC FORMATTED desc_col_temp_view key;
-- Describe a column with qualified name
DESC FORMATTED desc_col_temp_view desc_col_temp_view.key;
-- Describe a non-existent column
DESC desc_col_temp_view key1;
-- Test persistent table
CREATE TABLE desc_col_table (key int COMMENT 'column_comment') USING PARQUET;
ANALYZE TABLE desc_col_table COMPUTE STATISTICS FOR COLUMNS key;
DESC desc_col_table key;
DESC EXTENDED desc_col_table key;
DESC FORMATTED desc_col_table key;
-- Test complex columns
CREATE TABLE desc_complex_col_table (`a.b` int, col struct<x:int, y:string>) USING PARQUET;
DESC FORMATTED desc_complex_col_table `a.b`;
DESC FORMATTED desc_complex_col_table col;
-- Describe a nested column
DESC FORMATTED desc_complex_col_table col.x;
-- Test output for histogram statistics
SET spark.sql.statistics.histogram.enabled=true;
SET spark.sql.statistics.histogram.numBins=2;
INSERT INTO desc_col_table values 1, 2, 3, 4;
ANALYZE TABLE desc_col_table COMPUTE STATISTICS FOR COLUMNS key;
DESC EXTENDED desc_col_table key;
DROP VIEW desc_col_temp_view;
DROP TABLE desc_col_table;
DROP TABLE desc_complex_col_table;
--Test case insensitive
CREATE TABLE customer(CName STRING);
INSERT INTO customer VALUES('Maria');
ANALYZE TABLE customer COMPUTE STATISTICS FOR COLUMNS cname;
DESC EXTENDED customer cname;
DROP TABLE customer;