aresa7796 opened a new issue #3533:
URL: https://github.com/apache/hudi/issues/3533
Hi, guys
How to use MOR Table to Merge small file?
**Environment Description**
* Hudi version : 0.8.0
* Spark version : 3.1.2
* Hive version : 3.1.2
* Hadoop version : 3.1.2
* Storage (HDFS/S3/GCS..) : FS
* Running on Docker? (yes/no) : no
**My code**
```
object HudiExample {
def main(args: Array[String]): Unit = {
val config = ConfigFactory.load()
val conf = new SparkConf()
.setMaster("local[*]")
.set("spark.serializer", "org.apache.spark.serializer.KryoSerializer")
.set("spark.kryoserializer.buffer.max","512m")
.setAppName("hudi-batch")
val spark =
SparkSession.builder().enableHiveSupport().config(conf).getOrCreate()
spark.sparkContext.setLogLevel("error")
val data =
Seq("""{"timestamp":1628752653,"column1":"123","column2":"234"}""","""{"timestamp":1628752654,"column1":"2","column2":"2","type":
1}""")
import spark.implicits._
val ds = spark.createDataset(data)
var df = spark.read.json(ds)
df = df.selectExpr("uuid() as _track_id","*")
df.write
.format("org.apache.hudi")
.options(getQuickstartWriteConfigs)
.option(DataSourceWriteOptions.TABLE_TYPE_OPT_KEY,DataSourceWriteOptions.MOR_TABLE_TYPE_OPT_VAL)
.option(DataSourceWriteOptions.STORAGE_TYPE_OPT_KEY,DataSourceWriteOptions.MOR_STORAGE_TYPE_OPT_VAL)
.option(DataSourceWriteOptions.PRECOMBINE_FIELD_OPT_KEY, "timestamp")
.option(DataSourceWriteOptions.RECORDKEY_FIELD_OPT_KEY, "_track_id")
.option(HoodieIndexConfig.BLOOM_INDEX_UPDATE_PARTITION_PATH, "true")
.option(HoodieCompactionConfig.PARQUET_SMALL_FILE_LIMIT_BYTES,
104857600)
.option("hoodie.parquet.max.file.size", 134217728)
.option(HoodieIndexConfig.INDEX_TYPE_PROP,
HoodieIndex.IndexType.GLOBAL_BLOOM.name())
.option("hoodie.table.name", "hudi_example")
.mode(SaveMode.Append)
.save("/opt/hudi_example")
}
}
```
I executed this code many times,and multiple small files will be generated.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]