Skip to content

Commit fb7564a

Browse files
committed
Generate new test result.
1 parent dade338 commit fb7564a

File tree

3 files changed

+78
-94
lines changed

3 files changed

+78
-94
lines changed

sql/core/src/main/scala/org/apache/spark/sql/execution/SparkSqlParser.scala

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -426,41 +426,6 @@ class SparkSqlAstBuilder(conf: SQLConf) extends AstBuilder(conf) {
426426
Option(ctx.partitionSpec).map(visitNonOptionalPartitionSpec))
427427
}
428428

429-
/**
430-
* Create an [[AlterTableAddPartitionCommand]] command.
431-
*
432-
* For example:
433-
* {{{
434-
* ALTER TABLE table ADD [IF NOT EXISTS] PARTITION spec [LOCATION 'loc1']
435-
* ALTER VIEW view ADD [IF NOT EXISTS] PARTITION spec
436-
* }}}
437-
*
438-
* ALTER VIEW ... ADD PARTITION ... is not supported because the concept of partitioning
439-
* is associated with physical tables
440-
*/
441-
override def visitAddTablePartition(
442-
ctx: AddTablePartitionContext): LogicalPlan = withOrigin(ctx) {
443-
if (ctx.VIEW != null) {
444-
operationNotAllowed("ALTER VIEW ... ADD PARTITION", ctx)
445-
}
446-
// Create partition spec to location mapping.
447-
val specsAndLocs = if (ctx.partitionSpec.isEmpty) {
448-
ctx.partitionSpecLocation.asScala.map {
449-
splCtx =>
450-
val spec = visitNonOptionalPartitionSpec(splCtx.partitionSpec)
451-
val location = Option(splCtx.locationSpec).map(visitLocationSpec)
452-
spec -> location
453-
}
454-
} else {
455-
// Alter View: the location clauses are not allowed.
456-
ctx.partitionSpec.asScala.map(visitNonOptionalPartitionSpec(_) -> None)
457-
}
458-
AlterTableAddPartitionCommand(
459-
visitTableIdentifier(ctx.tableIdentifier),
460-
specsAndLocs,
461-
ctx.EXISTS != null)
462-
}
463-
464429
/**
465430
* Convert a nested constants list into a sequence of string sequences.
466431
*/

sql/core/src/test/resources/sql-tests/inputs/change-column.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ DESC test_change;
66
ALTER TABLE test_change CHANGE a;
77
DESC test_change;
88

9+
-- Change column name (not supported on v1 table)
10+
ALTER TABLE test_change RENAME COLUMN a TO a1;
11+
DESC test_change;
12+
913
-- Change column dataType (not supported yet)
1014
ALTER TABLE test_change CHANGE a TYPE STRING;
1115
DESC test_change;
Lines changed: 74 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-- Automatically generated by SQLQueryTestSuite
2-
-- Number of queries: 24
2+
-- Number of queries: 26
33

44

55
-- !query 0
@@ -45,12 +45,12 @@ c int
4545

4646

4747
-- !query 4
48-
ALTER TABLE test_change CHANGE a TYPE STRING
48+
ALTER TABLE test_change RENAME COLUMN a TO a1
4949
-- !query 4 schema
5050
struct<>
5151
-- !query 4 output
5252
org.apache.spark.sql.AnalysisException
53-
ALTER COLUMN is only supported with v2 tables.;
53+
RENAME COLUMN is only supported with v2 tables.;
5454

5555

5656
-- !query 5
@@ -64,10 +64,29 @@ c int
6464

6565

6666
-- !query 6
67-
ALTER TABLE test_change CHANGE a TYPE INT AFTER b
67+
ALTER TABLE test_change CHANGE a TYPE STRING
6868
-- !query 6 schema
6969
struct<>
7070
-- !query 6 output
71+
org.apache.spark.sql.AnalysisException
72+
ALTER TABLE CHANGE COLUMN is not supported for changing column 'a' with type 'IntegerType' to 'a' with type 'StringType';
73+
74+
75+
-- !query 7
76+
DESC test_change
77+
-- !query 7 schema
78+
struct<col_name:string,data_type:string,comment:string>
79+
-- !query 7 output
80+
a int
81+
b string
82+
c int
83+
84+
85+
-- !query 8
86+
ALTER TABLE test_change CHANGE a TYPE INT AFTER b
87+
-- !query 8 schema
88+
struct<>
89+
-- !query 8 output
7190
org.apache.spark.sql.catalyst.parser.ParseException
7291

7392
Operation not allowed: ALTER TABLE table CHANGE COLUMN ... FIRST | AFTER otherCol(line 1, pos 0)
@@ -77,11 +96,11 @@ ALTER TABLE test_change CHANGE a TYPE INT AFTER b
7796
^^^
7897

7998

80-
-- !query 7
99+
-- !query 9
81100
ALTER TABLE test_change CHANGE b TYPE STRING FIRST
82-
-- !query 7 schema
101+
-- !query 9 schema
83102
struct<>
84-
-- !query 7 output
103+
-- !query 9 output
85104
org.apache.spark.sql.catalyst.parser.ParseException
86105

87106
Operation not allowed: ALTER TABLE table CHANGE COLUMN ... FIRST | AFTER otherCol(line 1, pos 0)
@@ -91,145 +110,141 @@ ALTER TABLE test_change CHANGE b TYPE STRING FIRST
91110
^^^
92111

93112

94-
-- !query 8
113+
-- !query 10
95114
DESC test_change
96-
-- !query 8 schema
115+
-- !query 10 schema
97116
struct<col_name:string,data_type:string,comment:string>
98-
-- !query 8 output
117+
-- !query 10 output
99118
a int
100119
b string
101120
c int
102121

103122

104-
-- !query 9
105-
ALTER TABLE test_change CHANGE a TYPE INT COMMENT 'this is column a'
106-
-- !query 9 schema
107-
struct<>
108-
-- !query 9 output
109-
org.apache.spark.sql.AnalysisException
110-
ALTER COLUMN is only supported with v2 tables.;
111-
112-
113-
-- !query 10
114-
ALTER TABLE test_change CHANGE b TYPE STRING COMMENT '#*02?`'
115-
-- !query 10 schema
116-
struct<>
117-
-- !query 10 output
118-
org.apache.spark.sql.AnalysisException
119-
ALTER COLUMN is only supported with v2 tables.;
120-
121-
122123
-- !query 11
123-
ALTER TABLE test_change CHANGE c TYPE INT COMMENT ''
124+
ALTER TABLE test_change CHANGE a TYPE INT COMMENT 'this is column a'
124125
-- !query 11 schema
125126
struct<>
126127
-- !query 11 output
127-
org.apache.spark.sql.AnalysisException
128-
ALTER COLUMN is only supported with v2 tables.;
128+
129129

130130

131131
-- !query 12
132-
DESC test_change
132+
ALTER TABLE test_change CHANGE b TYPE STRING COMMENT '#*02?`'
133133
-- !query 12 schema
134-
struct<col_name:string,data_type:string,comment:string>
134+
struct<>
135135
-- !query 12 output
136-
a int
137-
b string
138-
c int
136+
139137

140138

141139
-- !query 13
142-
ALTER TABLE test_change CHANGE a TYPE INT COMMENT 'this is column a'
140+
ALTER TABLE test_change CHANGE c TYPE INT COMMENT ''
143141
-- !query 13 schema
144142
struct<>
145143
-- !query 13 output
146-
org.apache.spark.sql.AnalysisException
147-
ALTER COLUMN is only supported with v2 tables.;
144+
148145

149146

150147
-- !query 14
151148
DESC test_change
152149
-- !query 14 schema
153150
struct<col_name:string,data_type:string,comment:string>
154151
-- !query 14 output
155-
a int
156-
b string
152+
a int this is column a
153+
b string #*02?`
157154
c int
158155

159156

160157
-- !query 15
161-
ALTER TABLE test_change CHANGE invalid_col TYPE INT
158+
ALTER TABLE test_change CHANGE a TYPE INT COMMENT 'this is column a'
162159
-- !query 15 schema
163160
struct<>
164161
-- !query 15 output
165-
org.apache.spark.sql.AnalysisException
166-
ALTER COLUMN is only supported with v2 tables.;
162+
167163

168164

169165
-- !query 16
170166
DESC test_change
171167
-- !query 16 schema
172168
struct<col_name:string,data_type:string,comment:string>
173169
-- !query 16 output
174-
a int
175-
b string
170+
a int this is column a
171+
b string #*02?`
176172
c int
177173

178174

179175
-- !query 17
180-
CREATE TEMPORARY VIEW temp_view(a, b) AS SELECT 1, "one"
176+
ALTER TABLE test_change CHANGE invalid_col TYPE INT
181177
-- !query 17 schema
182178
struct<>
183179
-- !query 17 output
184-
180+
org.apache.spark.sql.AnalysisException
181+
Can't find column `invalid_col` given table data columns [`a`, `b`, `c`];
185182

186183

187184
-- !query 18
188-
ALTER TABLE temp_view CHANGE a TYPE INT COMMENT 'this is column a'
185+
DESC test_change
189186
-- !query 18 schema
190-
struct<>
187+
struct<col_name:string,data_type:string,comment:string>
191188
-- !query 18 output
192-
org.apache.spark.sql.AnalysisException
193-
Invalid command: 'temp_view' is a view not a table.; line 1 pos 0
189+
a int this is column a
190+
b string #*02?`
191+
c int
194192

195193

196194
-- !query 19
197-
CREATE GLOBAL TEMPORARY VIEW global_temp_view(a, b) AS SELECT 1, "one"
195+
CREATE TEMPORARY VIEW temp_view(a, b) AS SELECT 1, "one"
198196
-- !query 19 schema
199197
struct<>
200198
-- !query 19 output
201199

202200

203201

204202
-- !query 20
205-
ALTER TABLE global_temp.global_temp_view CHANGE a TYPE INT COMMENT 'this is column a'
203+
ALTER TABLE temp_view CHANGE a TYPE INT COMMENT 'this is column a'
206204
-- !query 20 schema
207205
struct<>
208206
-- !query 20 output
209207
org.apache.spark.sql.AnalysisException
210-
Invalid command: 'global_temp.global_temp_view' is a view not a table.; line 1 pos 0
208+
Invalid command: 'temp_view' is a view not a table.; line 1 pos 0
211209

212210

213211
-- !query 21
214-
DROP TABLE test_change
212+
CREATE GLOBAL TEMPORARY VIEW global_temp_view(a, b) AS SELECT 1, "one"
215213
-- !query 21 schema
216214
struct<>
217215
-- !query 21 output
218216

219217

220218

221219
-- !query 22
222-
DROP TABLE partition_table
220+
ALTER TABLE global_temp.global_temp_view CHANGE a TYPE INT COMMENT 'this is column a'
223221
-- !query 22 schema
224222
struct<>
225223
-- !query 22 output
226224
org.apache.spark.sql.AnalysisException
227-
Table or view not found: partition_table;
225+
Invalid command: 'global_temp.global_temp_view' is a view not a table.; line 1 pos 0
228226

229227

230228
-- !query 23
231-
DROP VIEW global_temp.global_temp_view
229+
DROP TABLE test_change
232230
-- !query 23 schema
233231
struct<>
234232
-- !query 23 output
235233

234+
235+
236+
-- !query 24
237+
DROP TABLE partition_table
238+
-- !query 24 schema
239+
struct<>
240+
-- !query 24 output
241+
org.apache.spark.sql.AnalysisException
242+
Table or view not found: partition_table;
243+
244+
245+
-- !query 25
246+
DROP VIEW global_temp.global_temp_view
247+
-- !query 25 schema
248+
struct<>
249+
-- !query 25 output
250+

0 commit comments

Comments
 (0)