hudi icon indicating copy to clipboard operation
hudi copied to clipboard

[SUPPORT] Deltastreamer: setting hoodie.datasource.hive_sync.partition_fields to blank results in empty partition being used in hive sync

Open andrewlaikh opened this issue 4 years ago • 6 comments

Describe the problem you faced

Deltastreamer: setting hoodie.datasource.hive_sync.partition_fields to blank results in empty partition being used in hive sync

To Reproduce

Steps to reproduce the behavior:

  1. Run a sample deltastreamer job and set hoodie.datasource.hive_sync.partition_fields= to empty
  2. Check hive schema upon creation

Expected behavior

Ideally, there should be no blank partition string, similar to how when hoodie.datasource.write.partitionpath.field= is set to blank, no partition paths are created. Not sure if this is the intended behavior

Environment Description

  • Hudi version : 0.10.1

  • Spark version : 3.1.2

  • Hive version : 3.1.2

  • Hadoop version : 2.10

  • Storage (HDFS/S3/GCS..) : HDFS

  • Running on Docker? (yes/no) : no

Additional context

Add any other context about the problem here.

Hive creation result

_hoodie_commit_time 	string              	                    
_hoodie_commit_seqno	string              	                    
_hoodie_record_key  	string              	                    
_hoodie_partition_path	string              	                    
_hoodie_file_name   	string              	                    
_event              	struct<type:string,database:string,table:string,isddl:boolean,es:bigint>	                    
rowkey_id          	bigint              	                    
ctime               	bigint              	                    
flag                	bigint              	                    
                    	string              	                    
	 	 
# Partition Information	 	 
# col_name            	data_type           	comment             
                    	string              	          
                    	```

andrewlaikh avatar Mar 23 '22 04:03 andrewlaikh

Some key generators such as ComplexKeyGenerator requires you to pass in hoodie.datasource.write.partitionpath.field= to indicate that the table is non-partitioned.

Seems like HoodieSyncConfig will infer this setting differently https://github.com/apache/hudi/blob/5f570ea151d0212ab1bb2d1f5693035626b76d31/hudi-sync/hudi-sync-common/src/main/java/org/apache/hudi/sync/common/HoodieSyncConfig.java#L113 and set partitionFields as a 1-length list containing "", which has different semantics to partitionFields = null.

Related question: is there a valid usecase for TypedProperties#getStringList of "" to return [""]?

qjqqyy avatar Mar 23 '22 13:03 qjqqyy

may I know why are you trying to explicitly set it to empty string. hudi will infer for you. you can skip setting it. Do you see any issues with that?

nsivabalan avatar Mar 27 '22 02:03 nsivabalan

@qjqqyy you're right. Do you want to work on the fix? Created HUDI-3922 to track this issue.

codope avatar Apr 20 '22 11:04 codope

hi @codope sure I would like to work on the fix, please add me (apache username jqi) as a contributor.

So to to summarise the problem at hand, ComplexKeyGenerator + no partition columns + HiveSync results in a broken Hive table.

  • for non-partitoned table, ComplexKeyGenerator requires hoodie.datasource.write.partitionpath.field to be set to empty string
  • when hoodie.datasource.hive_sync.partition_fields is not explicitly set, the inference function sets it to empty string
    • as OP is using Hudi 0.10.1, which does not auto-infer, it is just a minor annoyance of having to configure things inconsistently
  • there does not exist a combination of flags to produce a working hive table

I think the root cause is actually inconsistent handling of the degenerate case (empty string) between TypedProperties#getStringList and ComplexKeyGenerator.

qjqqyy avatar Apr 22 '22 19:04 qjqqyy

@qjqqyy You are added as a contributor in Hudi project on Jira. I assigned HUDI-3922 to you. Feel free to put up the suggested changes.

yihua avatar Apr 27 '22 01:04 yihua

closing this as we have a jira and a PR

nsivabalan avatar May 12 '22 19:05 nsivabalan