huangxiaopingRD commented on code in PR #11869:
URL: https://github.com/apache/hudi/pull/11869#discussion_r1741547127
##########
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/spark/sql/hudi/command/CreateHoodieTableCommand.scala:
##########
@@ -88,6 +92,20 @@ case class CreateHoodieTableCommand(table: CatalogTable,
ignoreIfExists: Boolean
object CreateHoodieTableCommand {
+ def validateTableSchema(userDefinedSchema: StructType, hoodieTableSchema:
StructType): Boolean = {
+ if (userDefinedSchema.fields.length != 0 &&
Review Comment:
Yes, the user's usage is
```
create table if not exists table_xxx (id string, name string, list string)
using hudi;
alter table table_xxx;
create table if not exists table_xxx (id string, name string, list
map<string, string>) using hudi;
```
but `alter table` does not perform the `purge` operation by default, so the
`.hoodie` directory is retained. When the user creates the table again, the
schema is changed, and `CreateHoodieTableCommand` still uses the `.hoodie`
schema to create the catalog table, resulting in write failure.
The purpose of this PR is to avoid such problems at the system level.
--
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]