Github user viirya commented on a diff in the pull request:
https://github.com/apache/spark/pull/10399#discussion_r57086648
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/types/Decimal.scala ---
@@ -376,6 +376,17 @@ object Decimal {
def apply(value: String): Decimal = new Decimal().set(BigDecimal(value))
+ // This is used for RowEncoder to handle Decimal inside external row.
+ def apply(value: Any): Decimal = {
+ value match {
+ case j: java.math.BigDecimal => apply(j)
+ case d: Decimal => d
+ case i: java.lang.Integer => apply(i.asInstanceOf[Int])
+ case l: java.lang.Long => apply(l.asInstanceOf[Long])
+ case d: java.lang.Double => apply(d.asInstanceOf[Double])
--- End diff --
Because as we have `apply(v: Any)`, java.lang.Integer will go to this
instead of apply(v: Int) above. The failed test above shows this problem. We
need to explicitly convert coming java.lang.Integer (Long, Double). In we want
to avoid the problem @cloud-fan mentioned, I think we need to add three apply
for this three java types.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]