watermelon12138 commented on issue #9799:
URL: https://github.com/apache/hudi/issues/9799#issuecomment-1808292380
@ad1happy2go @jefflee-jco
This following test case passed in hudi 0.14 version.
test("test bulk_insert") {
withTempDir { tmp =>
val tableName = generateTableName
val tablePath = s"${new Path(tmp.getCanonicalPath,
tableName).toUri.toString}"
import org.apache.spark.sql.types._
val rdd = spark.sparkContext.parallelize(Seq(
Row("James", null, "Smith", "36636", "M", 3000),
Row("Michael", "Rose", "", "40288", "M", 4000),
Row("Robert", null, "Williams", "42114", "M", 4000),
Row("Maria", "Anne", "Jones", "39192", "F", 4000),
Row("Jen", "Mary", "Brown", "", "F", -1)
))
val schema = StructType(
Seq(
StructField ("firstname", StringType, true),
StructField ("middlename", StringType, true),
StructField ("lastname", StringType, true),
StructField ("id", StringType, true),
StructField ("gender", StringType, true),
StructField ("salary", IntegerType, true)))
val df = spark.createDataFrame(rdd, schema)
df.write.format("hudi")
.option(DataSourceWriteOptions.TABLE_TYPE.key(),
COW_TABLE_TYPE_OPT_VAL)
.options(getQuickstartWriteConfigs)
.option(RECORDKEY_FIELD_OPT_KEY, "firstname,middlename")
.option(PRECOMBINE_FIELD_OPT_KEY, "id")
.option(PARTITIONPATH_FIELD_OPT_KEY, "id")
.option(HoodieWriteConfig.TBL_NAME.key(), tableName)
.option("hoodie.datasource.write.operation", "bulk_insert")
.option("hoodie.datasource.write.hive_style_partitioning", "true")
.mode(SaveMode.Overwrite).save(tablePath)
}
}
--
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]