watermelon12138 commented on issue #9991:
URL: https://github.com/apache/hudi/issues/9991#issuecomment-1801928047
@zyl891229
This is indeed a problem. But there is currently no perfect solution.
Reproducible code following:
test("data source api") {
withTempDir { tmp =>
val tableName = generateTableName
val tablePath = s"${new Path(tmp.getCanonicalPath,
tableName).toUri.toString}"
import org.apache.spark.sql.types._
val schema = StructType(List(
StructField("name", StringType, nullable = true),
StructField("age", IntegerType, nullable = true),
StructField("city", StringType, nullable = true)
))
val rdd = spark.sparkContext.parallelize(Seq(
Row("Bob", 18, "Xian"),
Row("richard", 20, "Zh")
))
val df = spark.createDataFrame(rdd, schema)
df.write.format("hudi")
.option(DataSourceWriteOptions.TABLE_TYPE.key(),
COW_TABLE_TYPE_OPT_VAL)
.options(getQuickstartWriteConfigs)
.option(PRECOMBINE_FIELD_OPT_KEY, "name")
.option(RECORDKEY_FIELD_OPT_KEY, "name")
.option(PARTITIONPATH_FIELD_OPT_KEY, "city,age")
.option(HoodieWriteConfig.TBL_NAME.key(), tableName)
.option(DataSourceWriteOptions.OPERATION.key(),
DataSourceWriteOptions.BULK_INSERT_OPERATION_OPT_VAL)
.option("hoodie.bulkinsert.overwrite.operation.type",
"insert_overwrite")
.option(DataSourceWriteOptions.HIVE_STYLE_PARTITIONING.key(), "true")
.option(HoodieTableConfig.POPULATE_META_FIELDS.key(), "true")
.option("hoodie.datasource.write.drop.partition.columns", "true")
.option(HoodieMetadataConfig.ENABLE.key(), "true")
.option("hoodie.metadata.index.column.stats.enable", "true")
.option("hoodie.metadata.index.column.stats.file.group.count", "8")
.option("hoodie.metadata.index.column.stats.parallelism", "10")
.option("hoodie.enable.data.skipping", "true")
.option(HoodieCleanConfig.CLEANER_POLICY.key(),
HoodieCleaningPolicy.KEEP_LATEST_FILE_VERSIONS.name())
.option(HoodieCleanConfig.CLEANER_FILE_VERSIONS_RETAINED.key(), "1")
.mode(SaveMode.Append).save(tablePath)
val df_result =
spark.read.format("hudi").load(tablePath).selectExpr("name")
assert(df_result.count() == 2)
}
}
--
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]