Skip to content

Commit 3ab96d7

Browse files
dilipbiswalcloud-fan
authored andcommitted
[SPARK-27444][SQL][FOLLOWUP][MINOR][TEST] Add a test for describing multi select query.
## What changes were proposed in this pull request? This is a minor pr to add a test to describe a multi select query. ## How was this patch tested? Added a test in describe-query.sql Closes apache#24370 from dilipbiswal/describe-query-multiselect-test. Authored-by: Dilip Biswal <[email protected]> Signed-off-by: Wenchen Fan <[email protected]>
1 parent 27d625d commit 3ab96d7

File tree

3 files changed

+30
-19
lines changed

3 files changed

+30
-19
lines changed

sql/core/src/main/scala/org/apache/spark/sql/execution/command/tables.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,9 @@ case class DescribeTableCommand(
635635
* 3. VALUES statement.
636636
* 4. TABLE statement. Example : TABLE table_name
637637
* 5. statements of the form 'FROM table SELECT *'
638-
* 6. Common table expressions (CTEs)
638+
* 6. Multi select statements of the following form:
639+
* select * from (from a select * select *)
640+
* 7. Common table expressions (CTEs)
639641
*/
640642
case class DescribeQueryCommand(query: LogicalPlan)
641643
extends DescribeCommandBase {

sql/core/src/test/resources/sql-tests/inputs/describe-query.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ DESC SELECT 10.00D as col1;
1010
DESC QUERY SELECT key FROM desc_temp1 UNION ALL select CAST(1 AS DOUBLE);
1111
DESC QUERY VALUES(1.00D, 'hello') as tab1(col1, col2);
1212
DESC QUERY FROM desc_temp1 a SELECT *;
13-
14-
15-
-- Error cases.
1613
DESC WITH s AS (SELECT 'hello' as col1) SELECT * FROM s;
1714
DESCRIBE QUERY WITH s AS (SELECT * from desc_temp1) SELECT * FROM s;
15+
DESCRIBE SELECT * FROM (FROM desc_temp2 select * select *);
16+
17+
-- Error cases.
1818
DESCRIBE INSERT INTO desc_temp1 values (1, 'val1');
1919
DESCRIBE INSERT INTO desc_temp1 SELECT * FROM desc_temp2;
2020
DESCRIBE

sql/core/src/test/resources/sql-tests/results/describe-query.sql.out

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-- Automatically generated by SQLQueryTestSuite
2-
-- Number of queries: 16
2+
-- Number of queries: 17
33

44

55
-- !query 0
@@ -97,10 +97,19 @@ val string
9797

9898

9999
-- !query 11
100-
DESCRIBE INSERT INTO desc_temp1 values (1, 'val1')
100+
DESCRIBE SELECT * FROM (FROM desc_temp2 select * select *)
101101
-- !query 11 schema
102-
struct<>
102+
struct<col_name:string,data_type:string,comment:string>
103103
-- !query 11 output
104+
key int
105+
val string
106+
107+
108+
-- !query 12
109+
DESCRIBE INSERT INTO desc_temp1 values (1, 'val1')
110+
-- !query 12 schema
111+
struct<>
112+
-- !query 12 output
104113
org.apache.spark.sql.catalyst.parser.ParseException
105114

106115
mismatched input 'desc_temp1' expecting {<EOF>, '.'}(line 1, pos 21)
@@ -110,11 +119,11 @@ DESCRIBE INSERT INTO desc_temp1 values (1, 'val1')
110119
---------------------^^^
111120

112121

113-
-- !query 12
122+
-- !query 13
114123
DESCRIBE INSERT INTO desc_temp1 SELECT * FROM desc_temp2
115-
-- !query 12 schema
124+
-- !query 13 schema
116125
struct<>
117-
-- !query 12 output
126+
-- !query 13 output
118127
org.apache.spark.sql.catalyst.parser.ParseException
119128

120129
mismatched input 'desc_temp1' expecting {<EOF>, '.'}(line 1, pos 21)
@@ -124,14 +133,14 @@ DESCRIBE INSERT INTO desc_temp1 SELECT * FROM desc_temp2
124133
---------------------^^^
125134

126135

127-
-- !query 13
136+
-- !query 14
128137
DESCRIBE
129138
FROM desc_temp1 a
130139
insert into desc_temp1 select *
131140
insert into desc_temp2 select *
132-
-- !query 13 schema
141+
-- !query 14 schema
133142
struct<>
134-
-- !query 13 output
143+
-- !query 14 output
135144
org.apache.spark.sql.catalyst.parser.ParseException
136145

137146
mismatched input 'insert' expecting {<EOF>, '(', ',', 'ANTI', 'CLUSTER', 'CROSS', 'DISTRIBUTE', 'EXCEPT', 'FULL', 'GROUP', 'HAVING', 'INNER', 'INTERSECT', 'JOIN', 'LATERAL', 'LEFT', 'LIMIT', 'NATURAL', 'ORDER', 'PIVOT', 'RIGHT', 'SELECT', 'SEMI', 'MINUS', 'SORT', 'UNION', 'WHERE', 'WINDOW'}(line 3, pos 5)
@@ -144,17 +153,17 @@ DESCRIBE
144153
insert into desc_temp2 select *
145154

146155

147-
-- !query 14
156+
-- !query 15
148157
DROP TABLE desc_temp1
149-
-- !query 14 schema
158+
-- !query 15 schema
150159
struct<>
151-
-- !query 14 output
160+
-- !query 15 output
152161

153162

154163

155-
-- !query 15
164+
-- !query 16
156165
DROP TABLE desc_temp2
157-
-- !query 15 schema
166+
-- !query 16 schema
158167
struct<>
159-
-- !query 15 output
168+
-- !query 16 output
160169

0 commit comments

Comments
 (0)