[SUPPORT] HiveSync not support schema evolution
- Dominant language
- Java
- Stars
- 6.2k
- Forks
- 2.5k
- Avg merge
- 2d 8h
- Merged PRs (30d)
- 111
Description
**Describe the problem you faced**
When I was testing schema evolution, I found that some exception occurred in synchronous hive.
**Environment Description**
* Hudi version : 0.13.1
* Hive version : 2.3.6
* Hadoop version : 2.10
* Flink version : 1.14.5
**Steps and exceptions**
- Test change column type
1. create table
```
create table if not exists ods_evolution1_hudi (
`id` int,
`name` int,
`create_date` string,
PRIMARY KEY(`id`) NOT ENFORCED
)
WITH (
'connector'='hudi',
'hoodie.datasource.write.hive_style_partitioning'='true',
'hoodie.datasource.write.partitionpath.field'='create_date',
'path'='file:///D:/data/hadoop/warehouse/test/ods_evolution1',
'hive_sync.metastore.uris'='thrift://xxx:9083',
'hive_sync.username'='',
'hive_sync.table'='ods_evolution1',
'hive_sync.enable'='true',
'hive_sync.password'='',
'hive_sync.db'='default',
'write.operation'='INSERT',
'hoodie.schema.on.read.enable'='true',
'hoodie.datasource.write.reconcile.schema'='true',
'table.type'='COPY_ON_WRITE'
)
```
2. insert `[2, 11, "2023-07-25"]` into ods_evolution1_hudi , `ods_evolution1` sync and select success!
3. change column type : `name int` -> `name string`
```
create table if not exists ods_evolution1_hudi (
`id` int,
`name` string,
`create_date` string,
PRIMARY KEY(`id`) NOT ENFORCED
)
WITH (
same options
)
```
5. insert `[1, "1", "2023-07-25"]` into ods_evolution1_hudi , write success but `ods_evolution1` sync failure!
```
Caused by: org.apache.hudi.hive.HoodieHiveSyncException: Could not convert field Type from INT to string for field name
at org.apache.hudi.hive.util.HiveSchemaUtil.getSchemaDifference(HiveSchemaUtil.java:118)
at org.apache.hudi.hive.HiveSyncTool.syncSchema(HiveSyncTool.java:335)
at org.apache.hudi.hive.HiveSyncTool.syncHoodieTable(HiveSyncTool.java:252)
```
6. `alter table ods_evolution1 change name name string`
7. select ods_evolution1 with exception
```
Failed with exception java.io.IOException:org.apache.hudi.exception.HoodieException: The gize of hive.io.file.readcolumn.ids:0.1,2.3.4,5.6.7 is not equal to projection columns: _hoodie_commit_time,_hoodie_commit_seqno,_hoodie_record_key,_hoodie_partition_path,_hoodie_file_name,id,name
```
**Questions**
1. Hive sync only support `int->bigint, float->double` ,refer to `HiveSchemaUtil#isSchemaTypeUpdateAllowed`
2. Why query failure in step 7 ?
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with HiveSchemaUtil#isSchemaTypeUpdateAllowed and the failure at HiveSchemaUtil.java:118, then trace HiveSyncTool.syncSchema and syncHoodieTable. Reproduce the supplied Flink, Hive, and Hudi schema-change steps, including the query failure after ALTER TABLE. Done requires determining the supported type evolution behavior and explaining or correcting both observed failures.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- hadoop, java, sql
- Domain
- data-engineering, databases, distributed-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100