apache / apache/hudi

Optimize auto partition in spark

Open
#14,994 1 comment 0 reactions 0 assignees View on GitHub
area:writer engine:spark from-jira priority:critical status:pr-available type:improvement
Dominant language
Java
Stars
6.2k
Forks
2.5k
Avg merge
2d 8h
Merged PRs (30d)
111

Description

recently, if partition's value has the format like "pt1=xxxx/pt2=yyyy/pt3=zzzz" which split by slash, Hudi will partition automatically. The directory of this table will have multi partition structure.

I think it's unpredictable. So create this umbrella task to optimize auto partition in order to make the behavior more reasonable.

Also, in hudi 0.8, schama will hold `pt1`, `pt2`, `pt3`, but not in 0.9+.

There are a few of sub tasks:
* add a flag to control whether enable auto-partition, to make the default behavior reasonable..
* achieve a new key generator designed specifically for this scenario.
* solve the bug about the different schema when enable *hoodie.file.index.enable* or not in this case.

 

Test Codes: 
{code:java}
import org.apache.hudi.QuickstartUtils._
import scala.collection.JavaConversions._
import org.apache.spark.sql.SaveMode._
import org.apache.hudi.DataSourceReadOptions._
import org.apache.hudi.DataSourceWriteOptions._
import org.apache.hudi.config.HoodieWriteConfig._

val tableName = "hudi_trips_cow"
val basePath = "file:///tmp/hudi_trips_cow"
val dataGen = new DataGenerator
val inserts = convertToStringList(dataGen.generateInserts(10))

val df = spark.read.json(spark.sparkContext.parallelize(inserts, 2))
val newDf = df.withColumn("partitionpath", regexp_replace($"partitionpath", "(.*)(\\/){1}(.*)(\\/){1}", "continent=$1$2country=$3$4city="))

newDf.write.format("hudi").
options(getQuickstartWriteConfigs).
option(PRECOMBINE_FIELD_OPT_KEY, "ts").
option(RECORDKEY_FIELD_OPT_KEY, "uuid").
option(PARTITIONPATH_FIELD_OPT_KEY, "partitionpath").
option(TABLE_NAME, tableName).
mode(Overwrite).
save(basePath) {code}

## JIRA info

- Link: https://issues.apache.org/jira/browse/HUDI-3214
- Type: Improvement

---

## Comments

28/Feb/22 14:16;xushiyan;[~biyan900116@gmail.com] what is the plan for this ticket? is it still a valid improvement?;;;

---

01/Mar/22 02:41;biyan900116@gmail.com;[~xushiyan] [~shivnarayan] I think no new configs or key generator needed here. i plan to enable `hoodie.datasource.write.partitionpath.urlencode` and `hoodie.datasource.write.hive_style_partitioning` by default. And if users want to auto discover partition from the partitionpath, they can disable `hoodie.datasource.write.partitionpath.urlencode`.;;;

---

20/Aug/22 17:20;xushiyan;need to triage if this is resolved already;;;

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the supplied Spark/Scala reproduction, especially the partitionpath transformation and the named Hudi write options. Read the discussion and triage whether the proposed flag, key generator, and schema fix are still needed. Done requires an agreed auto-partitioning behavior and resolution of the schema discrepancy when hoodie.file.index.enable differs.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, scala, spark
Domain
data-engineering
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.