leesf commented on a change in pull request #2177:
URL: https://github.com/apache/hudi/pull/2177#discussion_r506276147



##########
File path: 
hudi-spark/src/test/scala/org/apache/hudi/functional/TestCOWDataSource.scala
##########
@@ -194,4 +199,31 @@ class TestCOWDataSource extends HoodieClientTestBase {
       .load(basePath)
     assertEquals(hoodieIncViewDF2.count(), insert2NewKeyCnt)
   }
+
+  @Test def testComplexDataTypeWriteAndReadConsistency(): Unit = {
+    val records = Seq(ComplexDataTypeRecord("11", "Andy", 
Timestamp.valueOf("1970-01-01 13:31:24"), Date.valueOf("1991-11-07"), 
BigDecimal.valueOf(1.0), 11, 1),
+      ComplexDataTypeRecord("22", "lisi", Timestamp.valueOf("1970-01-02 
13:31:24"), Date.valueOf("1991-11-08"), BigDecimal.valueOf(2.0), 11, 1),
+      ComplexDataTypeRecord("33", "zhangsan", Timestamp.valueOf("1970-01-03 
13:31:24"), Date.valueOf("1991-11-09"), BigDecimal.valueOf(3.0), 11, 1))
+
+    val rdd = jsc.parallelize(records)
+    val  recordsDF = spark.createDataFrame(rdd)
+    recordsDF.write.format("org.apache.hudi")
+      .options(commonOpts)
+      .mode(SaveMode.Append)
+      .save(basePath)
+
+    val recordsReadDF = spark.read.format("org.apache.hudi")
+      .load(basePath + "/*/*")
+    recordsReadDF.schema.foreach(f => {
+      f.name match {
+        case "timeStampValue" =>
+          assertEquals(f.dataType, org.apache.spark.sql.types.TimestampType)
+        case "dateValue" =>
+          assertEquals(f.dataType, org.apache.spark.sql.types.DateType)
+        case "bigDecimalValue" =>
+          assertEquals(f.dataType, org.apache.spark.sql.types.DecimalType(38, 
18))

Review comment:
       here `(38, 18)` is decided by spark?




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

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


Reply via email to