apache / hudi

Upserts, Deletes And Incremental Processing on Big Data.
https://hudi.apache.org/
Apache License 2.0
5.33k stars 2.42k forks source link

[SUPPORT] Upgrading table through CLI changes from CustomKeyGenerator to SimpleKeyGenerator #11896

Open mzheng-plaid opened 1 week ago

mzheng-plaid commented 1 week ago

Describe the problem you faced

We found some old tables that were still table version 2 , these failed when trying to be read with Hudi 0.14.1 Spark jobs (could not recognize the hoodie.properties file).

To remediate I created a Spark job running with Hudi 0.12.2 so that I could run the upgrade table command to upgrade from table version 2 to table version 5 (and then in ingestion this would be upgraded to table version 6 on Hudi 0.14.1)

I was surprised to see the key generator class was changed/broken by the CLI:

╟─────────────────────────────────┼────────────────────────────────────────────────────────────────────────╢
║ fileSystem                      │ s3                                                                     ║
╟─────────────────────────────────┼────────────────────────────────────────────────────────────────────────╢
║ hoodie.table.name               │ ...                                                        ║
╟─────────────────────────────────┼────────────────────────────────────────────────────────────────────────╢
║ hoodie.table.recordkey.fields   │ _id                                                                    ║
╟─────────────────────────────────┼────────────────────────────────────────────────────────────────────────╢
║ hoodie.table.type               │ COPY_ON_WRITE                                                          ║
╟─────────────────────────────────┼────────────────────────────────────────────────────────────────────────╢
║ hoodie.table.precombine.field   │ published_at                                                           ║
╟─────────────────────────────────┼────────────────────────────────────────────────────────────────────────╢
║ hoodie.table.partition.fields   │ dt                                                                     ║
╟─────────────────────────────────┼────────────────────────────────────────────────────────────────────────╢
║ hoodie.table.keygenerator.class │ org.apache.hudi.keygen.CustomKeyGenerator                              ║
╟─────────────────────────────────┼────────────────────────────────────────────────────────────────────────╢
║ hoodie.populate.meta.fields     │ true                                                                   ║
╟─────────────────────────────────┼────────────────────────────────────────────────────────────────────────╢
║ hoodie.archivelog.folder        │ archived                                                               ║
╟─────────────────────────────────┼────────────────────────────────────────────────────────────────────────╢
║ hoodie.table.base.file.format   │ PARQUET                                                                ║
╟─────────────────────────────────┼────────────────────────────────────────────────────────────────────────╢
║ hoodie.timeline.layout.version  │ 1                                                                      ║
╟─────────────────────────────────┼────────────────────────────────────────────────────────────────────────╢
║ hoodie.table.version            │ 2                                                                      ║
╚═════════════════════════════════╧════════════════════════════════════════════════════════════════════════╝
╟─────────────────────────────────────────────────┼────────────────────────────────────────────────────────────────────────╢
║ fileSystem                                      │ s3                                                                     ║
╟─────────────────────────────────────────────────┼────────────────────────────────────────────────────────────────────────╢
║ hoodie.table.type                               │ COPY_ON_WRITE                                                          ║
╟─────────────────────────────────────────────────┼────────────────────────────────────────────────────────────────────────╢
║ hoodie.table.precombine.field                   │ published_at                                                           ║
╟─────────────────────────────────────────────────┼────────────────────────────────────────────────────────────────────────╢
║ hoodie.table.partition.fields                   │ dt                                                                     ║
╟─────────────────────────────────────────────────┼────────────────────────────────────────────────────────────────────────╢
║ hoodie.archivelog.folder                        │ archived                                                               ║
╟─────────────────────────────────────────────────┼────────────────────────────────────────────────────────────────────────╢
║ hoodie.timeline.layout.version                  │ 1                                                                      ║
╟─────────────────────────────────────────────────┼────────────────────────────────────────────────────────────────────────╢
║ hoodie.table.checksum                           │ 662017575                                                              ║
╟─────────────────────────────────────────────────┼────────────────────────────────────────────────────────────────────────╢
║ hoodie.table.name                               │ ...                                                        ║
╟─────────────────────────────────────────────────┼────────────────────────────────────────────────────────────────────────╢
║ hoodie.table.recordkey.fields                   │ _id                                                                    ║
╟─────────────────────────────────────────────────┼────────────────────────────────────────────────────────────────────────╢
║ hoodie.datasource.write.hive_style_partitioning │ false                                                                  ║
╟─────────────────────────────────────────────────┼────────────────────────────────────────────────────────────────────────╢
║ hoodie.table.keygenerator.class                 │ org.apache.hudi.keygen.SimpleKeyGenerator                              ║
╟─────────────────────────────────────────────────┼────────────────────────────────────────────────────────────────────────╢
║ hoodie.populate.meta.fields                     │ true                                                                   ║
╟─────────────────────────────────────────────────┼────────────────────────────────────────────────────────────────────────╢
║ hoodie.table.base.file.format                   │ PARQUET                                                                ║
╟─────────────────────────────────────────────────┼────────────────────────────────────────────────────────────────────────╢
║ hoodie.datasource.write.partitionpath.urlencode │ false                                                                  ║
╟─────────────────────────────────────────────────┼────────────────────────────────────────────────────────────────────────╢
║ hoodie.table.version                            │ 5                                                                      ║
╚═════════════════════════════════════════════════╧════════════════════════════════════════════════════════════════════════╝

To Reproduce

Steps to reproduce the behavior:

Create a table on Hudi 0.9.0, then run upgrade table to table version 5.

Expected behavior

The key generator should not be overwritten.

Environment Description

Additional context

This was done on EMR

danny0405 commented 1 week ago

Nice findings, @ad1happy2go , is this an known issue for upgrade?

ad1happy2go commented 6 days ago

@mzheng-plaid Normally we should not do upgrade directly from such a low version. If everything worked fine when going to 0.12 first and then 0.14, then we should be good.

mzheng-plaid commented 6 days ago

@ad1happy2go what do you mean? Do I need to manually upgrade from 2->3->4->5?

My point in this ticket is that 2->5 did not work and broke the table by changing the key generator class