You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by GitBox <gi...@apache.org> on 2020/10/14 17:16:57 UTC

[GitHub] [hudi] lw309637554 opened a new pull request #2177: [HUDI-307] add test to check data type write and read consistent

lw309637554 opened a new pull request #2177:
URL: https://github.com/apache/hudi/pull/2177


   …ead consistent
   
   ## *Tips*
   - *Thank you very much for contributing to Apache Hudi.*
   - *Please review https://hudi.apache.org/contributing.html before opening a pull request.*
   
   ## What is the purpose of the pull request
   
   add test to check timestamp date decimal type write and read consistent
   
   ## Brief change log
   
   *(for example:)*
     - *Modify AnnotationLocation checkstyle rule in checkstyle.xml*
   
   ## Verify this pull request
   
   *(Please pick either of the following options)*
   
   This pull request is a trivial rework / code cleanup without any test coverage.
   
   *(or)*
   
   This pull request is already covered by existing tests, such as *(please describe tests)*.
   
   (or)
   
   This change added tests and can be verified as follows:
   
   *(example:)*
   
     - *Added integration tests for end-to-end.*
     - *Added HoodieClientWriteTest to verify the change.*
     - *Manually verified the change by running a job locally.*
   
   ## Committer checklist
   
    - [ ] Has a corresponding JIRA in PR title & commit
    
    - [ ] Commit message is descriptive of the change
    
    - [ ] CI is green
   
    - [ ] Necessary doc changes done or have another open PR
          
    - [ ] For large changes, please consider breaking it into sub-tasks under an umbrella JIRA.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [hudi] lw309637554 commented on a change in pull request #2177: [HUDI-307] add test to check data type write and read consistent

Posted by GitBox <gi...@apache.org>.
lw309637554 commented on a change in pull request #2177:
URL: https://github.com/apache/hudi/pull/2177#discussion_r506954721



##########
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:
       @leesf  has set the schema use DataTypes.createDecimalType(15, 10) clearly.  This will be more clear




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [hudi] leesf merged pull request #2177: [HUDI-307] add test to check data type write and read consistent

Posted by GitBox <gi...@apache.org>.
leesf merged pull request #2177:
URL: https://github.com/apache/hudi/pull/2177


   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [hudi] lw309637554 commented on a change in pull request #2177: [HUDI-307] add test to check data type write and read consistent

Posted by GitBox <gi...@apache.org>.
lw309637554 commented on a change in pull request #2177:
URL: https://github.com/apache/hudi/pull/2177#discussion_r506287585



##########
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:
       yes,  spark will transform java  bigdecimal to SYSTEM_DEFAULT  decimal(38,18)




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [hudi] leesf commented on a change in pull request #2177: [HUDI-307] add test to check data type write and read consistent

Posted by GitBox <gi...@apache.org>.
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:
users@infra.apache.org