You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2019/01/04 09:13:01 UTC

[GitHub] jobar commented on a change in pull request #21012: [SPARK-23890][SQL] Support CHANGE COLUMN to add nested fields to structs

jobar commented on a change in pull request #21012: [SPARK-23890][SQL] Support CHANGE COLUMN to add nested fields to structs
URL: https://github.com/apache/spark/pull/21012#discussion_r245243876
 
 

 ##########
 File path: sql/core/src/test/scala/org/apache/spark/sql/execution/command/DDLSuite.scala
 ##########
 @@ -1693,16 +1698,41 @@ abstract class DDLSuite extends QueryTest with SQLTestUtils {
     val tableIdent = TableIdentifier("tab1", Some("dbx"))
     createDatabase(catalog, "dbx")
     createTable(catalog, tableIdent, isDatasourceTable)
-    def getMetadata(colName: String): Metadata = {
-      val column = catalog.getTableMetadata(tableIdent).schema.fields.find { field =>
+
+    def getColumnFromCatalog(colName: String): Option[StructField] = {
+      catalog.getTableMetadata(tableIdent).schema.fields.find { field =>
         resolver(field.name, colName)
       }
-      column.map(_.metadata).getOrElse(Metadata.empty)
+    }
+    def getMetadata(colName: String): Metadata = {
+      getColumnFromCatalog(colName).map(_.metadata).getOrElse(Metadata.empty)
     }
     // Ensure that change column will preserve other metadata fields.
     sql("ALTER TABLE dbx.tab1 CHANGE COLUMN col1 col1 INT COMMENT 'this is col1'")
     assert(getMetadata("col1").getString("key") == "value")
     assert(getMetadata("col1").getString("comment") == "this is col1")
+
+
+    // Ensure that change column with simple type change fails
+    intercept[AnalysisException] {
+      sql("ALTER TABLE dbx.tab1 CHANGE COLUMN col2 col2 INT")
+    }
+
+    // Ensure that change column with in nested column with type change fails
 
 Review comment:
   Typo plus not clear-  I'd say: `Ensure that change column changing type within nested-column fails`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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