imback82 commented on a change in pull request #33213:
URL: https://github.com/apache/spark/pull/33213#discussion_r664064796
##########
File path:
sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/v2/jdbc/JDBCTableCatalogSuite.scala
##########
@@ -321,7 +321,7 @@ class JDBCTableCatalogSuite extends QueryTest with
SharedSparkSession {
val msg = intercept[AnalysisException] {
sql(s"ALTER TABLE $tableName ALTER COLUMN bad_column COMMENT 'test'")
}.getMessage
- assert(msg.contains("Cannot update missing field bad_column in
h2.test.alt_table"))
+ assert(msg.contains("Missing field bad_column in table
h2.test.alt_table"))
Review comment:
If we are simplifying the message, we may not need to have
`AlterTableComand.operation`. I can remove it in #33200.
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala
##########
@@ -450,43 +450,6 @@ trait CheckAnalysis extends PredicateHelper with
LookupCatalog {
write.query.schema.foreach(f =>
TypeUtils.failWithIntervalType(f.dataType))
case alter: AlterTableCommand if alter.table.resolved =>
- val table = alter.table.asInstanceOf[ResolvedTable]
- def findField(fieldName: Seq[String]): StructField = {
- // Include collections because structs nested in maps and arrays
may be altered.
- val field = table.schema.findNestedField(fieldName,
includeCollections = true)
- if (field.isEmpty) {
- alter.failAnalysis(s"Cannot ${alter.operation} missing field
${fieldName.quoted} " +
- s"in ${table.name} schema: ${table.schema.treeString}")
- }
- field.get._2
- }
- def findParentStruct(fieldNames: Seq[String]): StructType = {
- val parent = fieldNames.init
- val field = if (parent.nonEmpty) {
- findField(parent).dataType
- } else {
- table.schema
- }
- field match {
- case s: StructType => s
- case o => alter.failAnalysis(s"Cannot ${alter.operation}
${fieldNames.quoted}, " +
- s"because its parent is not a StructType. Found $o")
- }
- }
- alter.transformExpressions {
- case UnresolvedFieldName(name) =>
- alter.failAnalysis(s"Cannot ${alter.operation} missing field
${name.quoted} in " +
- s"${table.name} schema: ${table.schema.treeString}")
- case UnresolvedFieldPosition(fieldName, position: After) =>
- val parent = findParentStruct(fieldName)
- val allFields = parent match {
- case s: StructType => s.fieldNames
- case o => alter.failAnalysis(s"Cannot ${alter.operation}
${fieldName.quoted}, " +
- s"because its parent is not a StructType. Found $o")
- }
- alter.failAnalysis(s"Couldn't resolve positional argument
$position amongst " +
Review comment:
`UnresolvedFieldPosition` was carrying `fieldName` to reconstruct this
message (no need to match by commands). If this is not needed anymore, we can
drop `fieldName`. Thanks for cleaning this up.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]