yihua commented on code in PR #12584:
URL: https://github.com/apache/hudi/pull/12584#discussion_r1907990293
##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/dml/TestMergeIntoTable2.scala:
##########
@@ -1030,4 +1031,175 @@ class TestMergeIntoTable2 extends
HoodieSparkSqlTestBase {
checkAnswer(s"show partitions $destTable")(Seq("dt=2022-09-26"))
}
}
+
+ test("Test MergeInto Anti-Patterns of assignment clauses") {
+ Seq("cow", "mor").foreach { tableType =>
+ withRecordType()(withTempDir { tmp =>
+ log.info(s"Testing table type $tableType")
+ spark.sql(s"set
${DataSourceWriteOptions.ENABLE_MERGE_INTO_PARTIAL_UPDATES.key} = false")
+ val tableName = generateTableName
+ // Create table with primaryKey and preCombineField
+ spark.sql(
+ s"""
+ |create table $tableName (
+ | id int,
+ | name string,
+ | price double,
+ | ts int,
+ | dt string
+ |) using hudi
+ | tblproperties (
+ | type = '$tableType',
+ | primaryKey = 'id',
+ | preCombineField = 'ts'
+ | )
+ | partitioned by(dt)
+ | location '${tmp.getCanonicalPath}'
+ """.stripMargin)
+
+ // Insert initial data
+ spark.sql(s"insert into $tableName values (1, 'a1', 10, 1000,
'2021-03-21')")
+
+ // Test 1: Update statements where at least one misses primary key
assignment
+ if (tableType.equals("mor")) {
Review Comment:
Could we also test the same SQL statements on COW table and make sure they
pass with data validation (i.e., the case where the new constraint does not
apply)?
--
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]