thesuperzapper commented on issue #24780: 
[SPARK-26388][SQL][WIP]_implement_hive_ddl_alter_table_replace_columns
URL: https://github.com/apache/spark/pull/24780#issuecomment-499309529
 
 
   @emanuelebardelli
   
   If we are trying to replicate [Hive's REPLACE COLUMN 
command](https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-Add/ReplaceColumns),
 we need to allow overwriting the entire schema of the table, regardless of if 
the final table will be readable.
   
   (The only exception is for table formats which it doesn't make sense, like 
ones which determine columns from index rather than name)
   
   I am not sure if your current approach will achieve this, can you confirm 
that:
   1. You can fully replace columns (including comments)
   1. You can reorder columns
   1. You can change the type of columns
       * There are cases where a new schema is able to read both old and new 
data without issues. What is allowed, depends on the format, e.g. PARQUET/AVRO. 
(This is often used for schema evolution)
       * Example: `STRUCT<`field1`: STRING>` →  `STRUCT<`field1`: STRING, 
`field2`: STRING>`
          * Note that this is __a column of type STRUCT__, not the full schema 
of a table
   
   Perhaps you could look into using one of the existing methods to overwrite 
the schema of the table, they are implemented in the various external catalogue 
classes. For example 
[HiveExternalCatalog.scala](https://github.com/apache/spark/blob/v2.4.3/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveExternalCatalog.scala#L647),
 which calls 
[HiveClient.scala](https://github.com/apache/spark/blob/v2.4.3/sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveClient.scala#L111).

----------------------------------------------------------------
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]

Reply via email to