wzx140 commented on code in PR #7003:
URL: https://github.com/apache/hudi/pull/7003#discussion_r1029474720


##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/TestInsertTable.scala:
##########
@@ -222,83 +223,85 @@ class TestInsertTable extends HoodieSparkSqlTestBase {
         Seq(3, "a3", 30.0, 3000, "20210103", "03"),
         Seq(4, "a4", 40.0, 4000, "20210104", "04")
       )
-    }
+    })
   }
 
   test("Test Insert Into None Partitioned Table") {
-    withTempDir { tmp =>
-      val tableName = generateTableName
-      spark.sql(s"set hoodie.sql.insert.mode=strict")
-      // Create none partitioned cow table
-      spark.sql(
-        s"""
-           |create table $tableName (
-           |  id int,
-           |  name string,
-           |  price double,
-           |  ts long
-           |) using hudi
-           | location '${tmp.getCanonicalPath}/$tableName'
-           | tblproperties (
-           |  type = 'cow',
-           |  primaryKey = 'id',
-           |  preCombineField = 'ts'
-           | )
-       """.stripMargin)
-      spark.sql(s"insert into $tableName values(1, 'a1', 10, 1000)")
-      checkAnswer(s"select id, name, price, ts from $tableName")(
-        Seq(1, "a1", 10.0, 1000)
-      )
-      spark.sql(s"insert into $tableName select 2, 'a2', 12, 1000")
-      checkAnswer(s"select id, name, price, ts from $tableName")(
-        Seq(1, "a1", 10.0, 1000),
-        Seq(2, "a2", 12.0, 1000)
-      )
-
-      assertThrows[HoodieDuplicateKeyException] {
-        try {
-          spark.sql(s"insert into $tableName select 1, 'a1', 10, 1000")
-        } catch {
-          case e: Exception =>
-            var root: Throwable = e
-            while (root.getCause != null) {
-              root = root.getCause
-            }
-            throw root
-        }
-      }
-      // Create table with dropDup is true
-      val tableName2 = generateTableName
-      spark.sql("set hoodie.datasource.write.insert.drop.duplicates = true")
-      spark.sql(
-        s"""
-           |create table $tableName2 (
-           |  id int,
-           |  name string,
-           |  price double,
-           |  ts long
-           |) using hudi
-           | location '${tmp.getCanonicalPath}/$tableName2'
-           | tblproperties (
-           |  type = 'mor',
-           |  primaryKey = 'id',
-           |  preCombineField = 'ts'
-           | )
-       """.stripMargin)
-      spark.sql(s"insert into $tableName2 select 1, 'a1', 10, 1000")
-      // This record will be drop when dropDup is true
-      spark.sql(s"insert into $tableName2 select 1, 'a1', 12, 1000")
-      checkAnswer(s"select id, name, price, ts from $tableName2")(
-        Seq(1, "a1", 10.0, 1000)
-      )
-      // disable this config to avoid affect other test in this class.
-      spark.sql("set hoodie.datasource.write.insert.drop.duplicates = false")
-      spark.sql(s"set hoodie.sql.insert.mode=upsert")
-    }
+   withRecordType(Map(HoodieRecordType.SPARK ->
+     Map(HoodieWriteConfig.MERGER_IMPLS.key ->
+       
classOf[HoodieSparkValidateDuplicateKeyRecordMerger].getName)))(withTempDir { 
tmp =>

Review Comment:
   Get it.



-- 
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: commits-unsubscr...@hudi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to