wombatu-kun commented on code in PR #20423:
URL: https://github.com/apache/hudi/pull/20423#discussion_r4356061092


##########
hudi-spark-datasource/hudi-spark3-common/src/main/scala/org/apache/spark/sql/hudi/command/CreateHoodieTableAsSelectCommand.scala:
##########
@@ -77,6 +77,17 @@ case class CreateHoodieTableAsSelectCommand(
         return Seq.empty
         // scalastyle:on
       }
+
+      if (mode == SaveMode.Append) {
+        val existingTable = 
sessionState.catalog.getTableMetadata(qualifiedTableIdentifier)
+        val partitionSpec = existingTable.partitionColumnNames.map((_, 
None)).toMap
+        InsertIntoHoodieTableCommand.run(sparkSession, existingTable, plan, 
partitionSpec,

Review Comment:
   Unlike `INSERT INTO`, this branch writes the query without 
`alignQueryOutput`, so a `BIGINT` column appended to an `INT` one widens the 
Hudi schema and makes `SELECT *` on the table fail with a 
`NullPointerException`, while an extra column lands in the Hudi schema but not 
the catalog and makes a later `INSERT INTO` with the declared columns fail with 
`NOT_ENOUGH_DATA_COLUMNS` (both reproduced through `saveAsTable`). Could 
`ResolveImplementationsEarly` apply `alignQueryOutput` against the existing 
table when the mode is `Append` and the table exists, with a test that appends 
a wider type?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to