Back to home page

OSCL-LXR

 
 

    


0001 -- Test temp table
0002 CREATE TEMPORARY VIEW desc_col_temp_view (key int COMMENT 'column_comment') USING PARQUET;
0003 
0004 DESC desc_col_temp_view key;
0005 
0006 DESC EXTENDED desc_col_temp_view key;
0007 
0008 DESC FORMATTED desc_col_temp_view key;
0009 
0010 -- Describe a column with qualified name
0011 DESC FORMATTED desc_col_temp_view desc_col_temp_view.key;
0012 
0013 -- Describe a non-existent column
0014 DESC desc_col_temp_view key1;
0015 
0016 -- Test persistent table
0017 CREATE TABLE desc_col_table (key int COMMENT 'column_comment') USING PARQUET;
0018 
0019 ANALYZE TABLE desc_col_table COMPUTE STATISTICS FOR COLUMNS key;
0020 
0021 DESC desc_col_table key;
0022 
0023 DESC EXTENDED desc_col_table key;
0024 
0025 DESC FORMATTED desc_col_table key;
0026 
0027 -- Test complex columns
0028 CREATE TABLE desc_complex_col_table (`a.b` int, col struct<x:int, y:string>) USING PARQUET;
0029 
0030 DESC FORMATTED desc_complex_col_table `a.b`;
0031 
0032 DESC FORMATTED desc_complex_col_table col;
0033 
0034 -- Describe a nested column
0035 DESC FORMATTED desc_complex_col_table col.x;
0036 
0037 -- Test output for histogram statistics
0038 SET spark.sql.statistics.histogram.enabled=true;
0039 SET spark.sql.statistics.histogram.numBins=2;
0040 
0041 INSERT INTO desc_col_table values 1, 2, 3, 4;
0042 
0043 ANALYZE TABLE desc_col_table COMPUTE STATISTICS FOR COLUMNS key;
0044 
0045 DESC EXTENDED desc_col_table key;
0046 
0047 DROP VIEW desc_col_temp_view;
0048 
0049 DROP TABLE desc_col_table;
0050 
0051 DROP TABLE desc_complex_col_table;
0052 
0053 --Test case insensitive
0054 
0055 CREATE TABLE customer(CName STRING) USING PARQUET;
0056 
0057 INSERT INTO customer VALUES('Maria');
0058 
0059 ANALYZE TABLE customer COMPUTE STATISTICS FOR COLUMNS cname;
0060 
0061 DESC EXTENDED customer cname;
0062 
0063 DROP TABLE customer;
0064