brkyvz commented on a change in pull request #27350: [SPARK-30615][SQL]
Introduce Analyzer rule for V2 AlterTable column change resolution
URL: https://github.com/apache/spark/pull/27350#discussion_r373094541
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala
##########
@@ -431,17 +431,37 @@ trait CheckAnalysis extends PredicateHelper {
// include collections because structs nested in maps and arrays
may be altered
val field = table.schema.findNestedField(fieldName,
includeCollections = true)
if (field.isEmpty) {
- throw new AnalysisException(
- s"Cannot $operation missing field in ${table.name} schema:
${fieldName.quoted}")
+ alter.failAnalysis(
+ s"Cannot $operation missing field ${fieldName.quoted} in
${table.name} schema: " +
+ table.schema.treeString)
+ }
+ field.get._2
+ }
+ def positionArgumentExists(position: ColumnPosition, dataType:
DataType): Boolean = {
+ (position, dataType) match {
+ case (after: After, struct: StructType) =>
+ struct.fieldNames.contains(after.column())
+ case (after: After, _) => false
Review comment:
Since this is used for non add-column methods as well, I left it a bit more
generic for now
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]