spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [spark] cloud-fan commented on a change in pull request #27350: [SPARK-30615][SQL] Introduce Analyzer rule for V2 AlterTable column change resolution
Date Thu, 30 Jan 2020 12:40:58 GMT
cloud-fan 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_r372925151
 
 

 ##########
 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:
   shall we fail for this case? We can't add fields to a non-struct column.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Mime
View raw message