wombatu-kun commented on code in PR #19990:
URL: https://github.com/apache/hudi/pull/19990#discussion_r4043321526
##########
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:
This `set` is never undone, so the later tests in this suite that do not set
the flag themselves (On Non-PK Condition, ignoring case, with Clustering, the
key-update error test) now run their UPDATEs with optimized writes off instead
of the default. Wrapping the two updates in
`withSQLConf(SPARK_SQL_OPTIMIZED_WRITES.key() ->
sparkSqlOptimizedWrites.toString) { ... }`, as the test above does, keeps it
scoped to this case.
--
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]