hudi icon indicating copy to clipboard operation
hudi copied to clipboard

[SUPPORT] - Hudi Read ,Partition Filter is coming empty.

Open rswagatika opened this issue 5 years ago • 6 comments

Describe the problem you faced

PartitionFilters are empty while filtering on the partition key from Hudi partition.

To Reproduce ** Write data with HUDI MOR ** hudi_options = { 'hoodie.table.name': table_name, 'hoodie.datasource.write.recordkey.field': 'posting_key', 'hoodie.datasource.write.partitionpath.field': 'range_partition', 'hoodie.datasource.write.table.name': table_name, 'hoodie.datasource.write.operation': 'upsert', 'hoodie.datasource.write.precombine.field': 'update_date', 'hoodie.datasource.write.table.type': 'MERGE_ON_READ', 'hoodie.cleaner.policy': 'KEEP_LATEST_FILE_VERSIONS', 'hoodie.consistency.check.enabled': True, 'hoodie.bloom.index.filter.type': 'dynamic_v0', 'hoodie.bloom.index.bucketized.checking': False, 'hoodie.memory.merge.max.size': '2004857600000', 'hoodie.upsert.shuffle.parallelism': 300, 'hoodie.parquet.small.file.limit': '204857600', 'hoodie.parquet.max.file.size': '334217728', 'hoodie.logfile.to.parquet.compression.ratio': '0.5', 'hoodie.memory.compaction.fraction': '384402653184', 'hoodie.clean.async': True, 'hoodie.clean.automatic': True, 'hoodie.cleaner.parallelism': 500, 'hoodie.compact.inline': True, 'hoodie.compact.inline.max.delta.commits': 2, 'hoodie.cleaner.commits.retained': 3, 'hoodie.keep.min.commits': 4, 'hoodie.keep.max.commits': 5, 'hoodie.copyonwrite.record.size.estimate': 32, 'hoodie.parquet.compression.ratio':'0.35', 'hoodie.logfile.max.size': '268435456' }

df.write.format("org.apache.hudi").options(**hudi_options).mode("append").save(path_to_delta_table)

spark.read.format("hudi").load("s3://testdataprocessing/Hudi_test//").filter("range_partition == 10 and posting_key > 20").explain(True)

Expected behavior

== Physical Plan ==
*(1) Project [_hoodie_commit_time#249, _hoodie_commit_seqno#250, _hoodie_record_key#251, _hoodie_partition_path#252, _hoodie_file_name#253, locations#254, posting_key#255L, update_date#256, range_partition#257L]
+- *(1) Filter (((isnotnull(range_partition#257L) && isnotnull(posting_key#255L)) && (range_partition#257L = 10)) && (posting_key#255L > 20))
   +- *(1) FileScan parquet [_hoodie_commit_time#249,_hoodie_commit_seqno#250,_hoodie_record_key#251,_hoodie_partition_path#252,_hoodie_file_name#253,locations#254,posting_key#255L,update_date#256,range_partition#257L] Batched: false, Format: Parquet, Location: InMemoryFileIndex[s3://bgt-atlas-emr-devtest/testdataprocessing/Range_partition_Hudi_test5/.hoodi..., PartitionFilters: [], PushedFilters: [IsNotNull(range_partition), IsNotNull(posting_key), EqualTo(range_partition,10), GreaterThan(pos..., ReadSchema: struct<_hoodie_commit_time:string,_hoodie_commit_seqno:string,_hoodie_record_key:string,_hoodie_p...

PartitionFilters: [] is coming empty where I expected it to have the partitioned folder. So I am not sure, here is it scanning all the partition?

Environment Description

  • Hudi version : 0.6.0

  • Spark version : 2.4.6

  • EMR version : 5.31.0

  • Hadoop version : 2.10.0

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

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

rswagatika avatar Dec 23 '20 22:12 rswagatika

hi, how's your partition naming looks like? is that in hive style with column name prefix like year=2020? The partition is based on Spark partition auto-discovery so the naming must be in hive style.

garyli1019 avatar Dec 26 '20 08:12 garyli1019

My partition does not look like hive style when am using Hudi write.

The below is the screenshot, how my partition looks like.

Screen Shot 2020-12-27 at 11 27 23 AM

rswagatika avatar Dec 27 '20 16:12 rswagatika

Hi, Spark only can recognize hive style partitioning. Please refer to this doc: https://spark.apache.org/docs/latest/sql-data-sources-parquet.html#partition-discovery

garyli1019 avatar Dec 28 '20 02:12 garyli1019

Hi , I have added the config for hive style partitioning and in my partition I could see the hive style partitons.

Screen Shot 2020-12-28 at 3 04 16 PM

However if I do a filter on read still the Partition Filter is empty in my Physical Plan. My question is does hudi scan all the partitioned folder in this case or does it only look up the partitioned folder I specified in the read.

queryHudiRead = spark.read.format("hudi").load("s3://testdataprocessing/Partition_test13/*/*").filter("range_partition == 10 and posting_key > 20")
queryHudiRead.explain(extended=True)

== Physical Plan == *(1) Project [_hoodie_commit_time#281, _hoodie_commit_seqno#282, _hoodie_record_key#283, _hoodie_partition_path#284, _hoodie_file_name#285, locations#286, posting_key#287L, update_date#288, range_partition#289L] +- *(1) Filter (((isnotnull(range_partition#289L) && isnotnull(posting_key#287L)) && (range_partition#289L = 10)) && (posting_key#287L > 20)) +- *(1) FileScan parquet [_hoodie_commit_time#281,_hoodie_commit_seqno#282,_hoodie_record_key#283,_hoodie_partition_path#284,_hoodie_file_name#285,locations#286,posting_key#287L,update_date#288,range_partition#289L] Batched: false, Format: Parquet, Location: InMemoryFileIndex[s3://bgt-atlas-emr-devtest/testdataprocessing/WOutHive_Partition_test13/.hoodie..., PartitionFilters: [], PushedFilters: [IsNotNull(range_partition), IsNotNull(posting_key), EqualTo(range_partition,10), GreaterThan(pos..., ReadSchema: struct<_hoodie_commit_time:string,_hoodie_commit_seqno:string,_hoodie_record_key:string,_hoodie_p...

rswagatika avatar Dec 28 '20 20:12 rswagatika

please try.load("s3://testdataprocessing/Partition_test13"), spark won't load the partition if you use the blob path. I think the documentation mentioned this as well. if your dataset already has a range_partition column then it won't work too. Spark will try to load the partition based on the folder's name.

garyli1019 avatar Dec 29 '20 15:12 garyli1019

@garyli1019 Thank you for your response and help.I was able to see the partition filter removing the // .

rswagatika avatar Dec 29 '20 17:12 rswagatika