You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "ottomata (via GitHub)" <gi...@apache.org> on 2024/01/02 15:00:48 UTC

Re: [PR] [SPARK-23890][SQL] Support DDL for adding nested columns to struct types [spark]

ottomata commented on PR #21012:
URL: https://github.com/apache/spark/pull/21012#issuecomment-1874135870

   Ah, sorry, my scala goggles weren't on quite right.  According to `verifyAlterTableAddColumn`, e.g. JsonDataSourceV2 is supported for ALTER TABLE ADD COLUMN.  We don't need to change that check at all.
   
   What we need to change is the check in ResolveCatalogSession that does
   ```scala
   throw QueryCompilationErrors.unsupportedTableOperationError(ident, "ADD COLUMN with qualified column")
   ```
   
   `if c.name.length > 1`.  
   However, if I remove that, I can see a problem in the way `AlterTableAddColumnsCommand` is implemented: it takes a `Seq[StructField]` as the list of columns to add.  This list is constructed by `convertToStructField` in ResolveSessionCatalog, which naively assumes that the col to add is not nested: 
   ```scala
       StructField(col.name.head, col.dataType, nullable = true, builder.build())
   ```
   Returns a StructField with the top level column name but the nested leaf column's DataType.
   
   
    


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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