yihua commented on code in PR #12800:
URL: https://github.com/apache/hudi/pull/12800#discussion_r1973808072


##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/TestTableColumnTypeMismatch.scala:
##########
@@ -915,6 +915,82 @@ class TestTableColumnTypeMismatch extends 
HoodieSparkSqlTestBase with ScalaAsser
       })
     }
   }
+
+  test("Test Type Casting with Global Index for Primary Key and Partition Key 
Updates") {
+    Seq("cow", "mor").foreach { tableType =>
+      withRecordType()(withTempDir { tmp =>

Review Comment:
   Fixed.



##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/TestTableColumnTypeMismatch.scala:
##########
@@ -915,6 +915,82 @@ class TestTableColumnTypeMismatch extends 
HoodieSparkSqlTestBase with ScalaAsser
       })
     }
   }
+
+  test("Test Type Casting with Global Index for Primary Key and Partition Key 
Updates") {
+    Seq("cow", "mor").foreach { tableType =>
+      withRecordType()(withTempDir { tmp =>
+        withSQLConf("hoodie.index.type" -> "GLOBAL_SIMPLE",
+          "hoodie.simple.index.update.partition.path" -> "true") {
+          val tableName = generateTableName
+
+          // Create table with both primary key and partition key
+          spark.sql(
+            s"""
+               |create table $tableName (
+               |  c1 int,
+               |  c2 int,
+               |  c3 string,
+               |  ts long
+               |) using hudi
+               |partitioned by (c2)
+               |location '${tmp.getCanonicalPath}/$tableName'
+               |tblproperties (
+               |  type = '$tableType',
+               |  primaryKey = 'c1',
+               |  preCombineField = 'ts'
+               |)
+           """.stripMargin)
+
+          // Test Case 1: Initial insert with double values
+          spark.sql(
+            s"""
+               |insert into $tableName
+               |select
+               |  cast(1.0 as double) as c1,
+               |  cast(1.0 as double) as c2,
+               |  'a' as c3,
+               |  1000 as ts
+           """.stripMargin)
+
+          // Verify initial insert
+          checkAnswer(
+            s"select c1, c2, c3 from $tableName")(
+            Seq(1, 1, "a")
+          )
+
+          // Test Case 2 [Not supported]: Update partition key (c2)
+          // spark.sql(
+          //   s"""
+          //      |update $tableName
+          //      |set c2 = cast(2.0 as double)
+          //      |where c3 = 'a'
+          //  """.stripMargin)
+          // // Verify partition key update
+          // checkAnswer(
+          //   s"select c1, c2, c3 from $tableName")(
+          //   Seq(1, 2, "a")
+          // )

Review Comment:
   Fixed.



-- 
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]

Reply via email to