You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by GitBox <gi...@apache.org> on 2022/03/01 00:36:51 UTC
[GitHub] [hudi] nsivabalan commented on issue #4914: [SUPPORT] reconcile schema failing to inject default values for missing fields
nsivabalan commented on issue #4914:
URL: https://github.com/apache/hudi/issues/4914#issuecomment-1054853406
schema has to be backwards compatible and new fields has to be added towards the end. From your example, the field of interest is "name" which is in the middle.
```
inputDF = spark.createDataFrame(
[
("100", "AAA", "2015-01-01", "2015-01-01T13:51:39.340396Z", "2015-01-01"),
("101", "BBB", "2015-01-01", "2015-01-01T12:14:58.597216Z", "2015-01-01"),
("102", "CCC", "2015-01-01", "2015-01-01T13:51:40.417052Z", "2015-01-01"),
("103", "DDD", "2015-01-01", "2015-01-01T13:51:40.519832Z", "2015-01-01"),
("104", "EEE", "2015-01-01", "2015-01-01T12:15:00.512679Z", "2015-01-01"),
("105", "FFF", "2015-01-01", "2015-01-01T13:51:42.248818Z", "2015-01-01")
],
["id", "name", "creation_date", "last_update_time", "creation_date_1"]
)
table_name = "first_hudi_table"
table_path = f"s3://<bucket_name>/Hudi/{table_name}"
hudiOptions = {
'hoodie.table.name': table_name,
'hoodie.datasource.write.recordkey.field': 'id',
'hoodie.datasource.write.precombine.field': 'last_update_time',
}
print(table_name, table_path)
inputDF.write\
.format('hudi')\
.option('hoodie.datasource.write.operation', 'insert')\
.options(**hudiOptions)\
.mode('overwrite')\
.save(table_path)
inputDF = spark.createDataFrame(
[
("100", "AAA", "2015-01-01", "2015-01-01T13:51:39.340396Z"),
("101", "BBB", "2015-01-01", "2015-01-01T12:14:58.597216Z"),
("102", "CCC", "2015-01-01", "2015-01-01T13:51:40.417052Z"),
("103", "DDD", "2015-01-01", "2015-01-01T13:51:40.519832Z"),
("104", "EEE", "2015-01-01", "2015-01-01T12:15:00.512679Z"),
("105", "FFF", "2015-01-01", "2015-01-01T13:51:42.248818Z")
],
["id", "name", "creation_date", "last_update_time"]
)
hudiOptions = {
'hoodie.table.name': table_name,
'hoodie.datasource.write.recordkey.field': 'id',
'hoodie.datasource.write.precombine.field': 'last_update_time',
'hoodie.datasource.write.reconcile.schema': 'true',
}
inputDF.write\
.format('hudi')\
.option('hoodie.datasource.write.operation', 'insert')\
.options(**hudiOptions)\
.mode('append')\
.save(table_path)
```
This works.
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org