Skip to content

Commit 0da0219

Browse files
committed
fix tests
1 parent 00a7607 commit 0da0219

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

sql/core/src/test/resources/sql-tests/results/change-column.sql.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ ALTER TABLE temp_view CHANGE a TYPE INT
221221
struct<>
222222
-- !query output
223223
org.apache.spark.sql.AnalysisException
224-
Invalid command: 'temp_view' is a view not a table.; line 1 pos 0
224+
temp_view is a temp view. 'ALTER TABLE ... CHANGE COLUMN' expects a table.; line 1 pos 12
225225

226226

227227
-- !query
@@ -238,7 +238,7 @@ ALTER TABLE global_temp.global_temp_view CHANGE a TYPE INT
238238
struct<>
239239
-- !query output
240240
org.apache.spark.sql.AnalysisException
241-
Invalid command: 'global_temp.global_temp_view' is a view not a table.; line 1 pos 0
241+
global_temp.global_temp_view is a temp view. 'ALTER TABLE ... CHANGE COLUMN' expects a table.; line 1 pos 12
242242

243243

244244
-- !query

sql/core/src/test/scala/org/apache/spark/sql/execution/command/DDLSuite.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2310,7 +2310,8 @@ abstract class DDLSuite extends QueryTest with SQLTestUtils {
23102310
val e = intercept[AnalysisException] {
23112311
sql("ALTER TABLE tmp_v ADD COLUMNS (c3 INT)")
23122312
}
2313-
assert(e.message.contains("'tmp_v' is a view not a table"))
2313+
assert(e.message.contains(
2314+
"tmp_v is a temp view. 'ALTER TABLE ... ADD COLUMNS' expects a table."))
23142315
}
23152316
}
23162317

@@ -2320,7 +2321,8 @@ abstract class DDLSuite extends QueryTest with SQLTestUtils {
23202321
val e = intercept[AnalysisException] {
23212322
sql("ALTER TABLE v1 ADD COLUMNS (c3 INT)")
23222323
}
2323-
assert(e.message.contains("ALTER ADD COLUMNS does not support views"))
2324+
assert(e.message.contains(
2325+
"default.v1 is a view. 'ALTER TABLE ... ADD COLUMNS' expects a table."))
23242326
}
23252327
}
23262328

sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/v2/jdbc/JDBCTableCatalogSuite.scala

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ class JDBCTableCatalogSuite extends QueryTest with SharedSparkSession {
240240
val msg = intercept[AnalysisException] {
241241
sql(s"ALTER TABLE $tableName DROP COLUMN bad_column")
242242
}.getMessage
243-
assert(msg.contains("Cannot delete missing field bad_column in test.alt_table schema"))
243+
assert(msg.contains("Cannot delete missing field bad_column in h2.test.alt_table schema"))
244244
}
245245
// Drop a column to not existing table and namespace
246246
Seq("h2.test.not_existing_table", "h2.bad_test.not_existing_table").foreach { table =>
@@ -266,7 +266,7 @@ class JDBCTableCatalogSuite extends QueryTest with SharedSparkSession {
266266
val msg1 = intercept[AnalysisException] {
267267
sql(s"ALTER TABLE $tableName ALTER COLUMN bad_column TYPE DOUBLE")
268268
}.getMessage
269-
assert(msg1.contains("Cannot update missing field bad_column in test.alt_table schema"))
269+
assert(msg1.contains("Cannot update missing field bad_column in h2.test.alt_table schema"))
270270
// Update column to wrong type
271271
val msg2 = intercept[ParseException] {
272272
sql(s"ALTER TABLE $tableName ALTER COLUMN id TYPE bad_type")
@@ -297,7 +297,7 @@ class JDBCTableCatalogSuite extends QueryTest with SharedSparkSession {
297297
val msg = intercept[AnalysisException] {
298298
sql(s"ALTER TABLE $tableName ALTER COLUMN bad_column DROP NOT NULL")
299299
}.getMessage
300-
assert(msg.contains("Cannot update missing field bad_column in test.alt_table"))
300+
assert(msg.contains("Cannot update missing field bad_column in h2.test.alt_table"))
301301
}
302302
// Update column nullability in not existing table and namespace
303303
Seq("h2.test.not_existing_table", "h2.bad_test.not_existing_table").foreach { table =>
@@ -321,7 +321,7 @@ class JDBCTableCatalogSuite extends QueryTest with SharedSparkSession {
321321
val msg = intercept[AnalysisException] {
322322
sql(s"ALTER TABLE $tableName ALTER COLUMN bad_column COMMENT 'test'")
323323
}.getMessage
324-
assert(msg.contains("Cannot update missing field bad_column in test.alt_table"))
324+
assert(msg.contains("Cannot update missing field bad_column in h2.test.alt_table"))
325325
}
326326
// Update column comments in not existing table and namespace
327327
Seq("h2.test.not_existing_table", "h2.bad_test.not_existing_table").foreach { table =>
@@ -346,7 +346,7 @@ class JDBCTableCatalogSuite extends QueryTest with SharedSparkSession {
346346
val msg = intercept[AnalysisException] {
347347
sql(s"ALTER TABLE $tableName RENAME COLUMN C2 TO c3")
348348
}.getMessage
349-
assert(msg.contains("Cannot rename missing field C2 in test.alt_table schema"))
349+
assert(msg.contains("Cannot rename missing field C2 in h2.test.alt_table schema"))
350350
}
351351

352352
withSQLConf(SQLConf.CASE_SENSITIVE.key -> "false") {
@@ -362,7 +362,7 @@ class JDBCTableCatalogSuite extends QueryTest with SharedSparkSession {
362362
val msg = intercept[AnalysisException] {
363363
sql(s"ALTER TABLE $tableName DROP COLUMN C3")
364364
}.getMessage
365-
assert(msg.contains("Cannot delete missing field C3 in test.alt_table schema"))
365+
assert(msg.contains("Cannot delete missing field C3 in h2.test.alt_table schema"))
366366
}
367367

368368
withSQLConf(SQLConf.CASE_SENSITIVE.key -> "false") {
@@ -376,7 +376,7 @@ class JDBCTableCatalogSuite extends QueryTest with SharedSparkSession {
376376
val msg = intercept[AnalysisException] {
377377
sql(s"ALTER TABLE $tableName ALTER COLUMN C1 TYPE DOUBLE")
378378
}.getMessage
379-
assert(msg.contains("Cannot update missing field C1 in test.alt_table schema"))
379+
assert(msg.contains("Cannot update missing field C1 in h2.test.alt_table schema"))
380380
}
381381

382382
withSQLConf(SQLConf.CASE_SENSITIVE.key -> "false") {
@@ -390,7 +390,7 @@ class JDBCTableCatalogSuite extends QueryTest with SharedSparkSession {
390390
val msg = intercept[AnalysisException] {
391391
sql(s"ALTER TABLE $tableName ALTER COLUMN C1 DROP NOT NULL")
392392
}.getMessage
393-
assert(msg.contains("Cannot update missing field C1 in test.alt_table schema"))
393+
assert(msg.contains("Cannot update missing field C1 in h2.test.alt_table schema"))
394394
}
395395

396396
withSQLConf(SQLConf.CASE_SENSITIVE.key -> "false") {

0 commit comments

Comments
 (0)