Skip to content

Commit 48fc338

Browse files
committed
update error message.
1 parent 6035d7e commit 48fc338

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,8 @@ case class AlterTableChangeColumnCommand(
344344
schema.fields.collectFirst {
345345
case field if resolver(field.name, name) => field
346346
}.getOrElse(throw new AnalysisException(
347-
s"Invalid column reference '$name', table data schema is '${schema}'"))
347+
s"Can't find column `$name` given table data columns " +
348+
s"${schema.fieldNames.mkString("[`", "`, `", "`]")}"))
348349
}
349350

350351
// Add the comment to a column, if comment is empty, return the original column.

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
@@ -154,7 +154,7 @@ ALTER TABLE test_change CHANGE invalid_col invalid_col INT
154154
struct<>
155155
-- !query 15 output
156156
org.apache.spark.sql.AnalysisException
157-
Invalid column reference 'invalid_col', table data schema is 'StructType(StructField(a,IntegerType,true), StructField(b,StringType,true), StructField(c,IntegerType,true))';
157+
Can't find column `invalid_col` given table data columns [`a`, `b`, `c`];
158158

159159

160160
-- !query 16
@@ -296,7 +296,7 @@ ALTER TABLE partition_table CHANGE COLUMN c c INT COMMENT 'this is column C'
296296
struct<>
297297
-- !query 30 output
298298
org.apache.spark.sql.AnalysisException
299-
Invalid column reference 'c', table data schema is 'StructType(StructField(a,IntegerType,true), StructField(b,StringType,true))';
299+
Can't find column `c` given table data columns [`a`, `b`];
300300

301301

302302
-- !query 31

0 commit comments

Comments
 (0)