You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2018/12/14 12:19:56 UTC

[GitHub] holdenk commented on a change in pull request #23308: [SPARK-26308][SQL] Infer abstract decimal type for java/scala BigDecimal

holdenk commented on a change in pull request #23308: [SPARK-26308][SQL] Infer abstract decimal type for java/scala BigDecimal
URL: https://github.com/apache/spark/pull/23308#discussion_r241732124
 
 

 ##########
 File path: sql/core/src/test/scala/org/apache/spark/sql/UDFSuite.scala
 ##########
 @@ -420,4 +420,14 @@ class UDFSuite extends QueryTest with SharedSQLContext {
       checkAnswer(df, Seq(Row("null1x"), Row(null), Row("N3null")))
     }
   }
+
+  test("SPARK-26308: udf with decimal") {
+    val df1 = spark.createDataFrame(
+      sparkContext.parallelize(Seq(Row(new java.math.BigDecimal("2011000000000002456556")))),
+      StructType(Seq(StructField("col1", DecimalType(30, 0)))))
+    val udf1 = org.apache.spark.sql.functions.udf((value: java.math.BigDecimal) => {
+      if (value == null) null else value.toBigInteger.toString
 
 Review comment:
   In which case is the value null? If there is a case we should have a test for it 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org