yihua commented on code in PR #19990:
URL: https://github.com/apache/hudi/pull/19990#discussion_r4043805833
##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/dml/others/TestUpdateTable.scala:
##########
@@ -81,6 +82,52 @@ class TestUpdateTable extends HoodieSparkSqlTestBase {
})
}
+ test("Test Update Table With Row Merge Handle") {
+ // Same statements as above with the merge handle pinned to
HoodieWriteMergeHandle, so the write
+ // builds payload-carrying records and merges on the ordering value each
record carries.
+ withRecordType()(withTempDir { tmp =>
+ Seq(true, false).foreach { sparkSqlOptimizedWrites =>
+ Seq("cow", "mor").foreach { tableType =>
+ val tableName = generateTableName
+ spark.sql(
+ s"""
+ |create table $tableName (
+ | id int,
+ | name string,
+ | price double,
+ | ts long
+ |) using hudi
+ | location '${tmp.getCanonicalPath}/$tableName'
+ | tblproperties (
+ | type = '$tableType',
+ | primaryKey = 'id',
+ | preCombineField = 'ts',
+ | '${HoodieWriteConfig.MERGE_HANDLE_CLASS_NAME.key()}' =
'org.apache.hudi.io.HoodieWriteMergeHandle'
+ | )
+ """.stripMargin)
+
+ spark.sql(s"insert into $tableName select 1, 'a1', 10, 1000")
+ checkAnswer(s"select id, name, price, ts from $tableName")(
+ Seq(1, "a1", 10.0, 1000)
+ )
+
+ spark.sql(s"set
${SPARK_SQL_OPTIMIZED_WRITES.key()}=$sparkSqlOptimizedWrites")
Review Comment:
Done, the two updates are now inside
withSQLConf(SPARK_SQL_OPTIMIZED_WRITES.key() -> ...) like the test above, so
the flag no longer leaks into the later cases.
--
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]