Github user marmbrus commented on a diff in the pull request:
https://github.com/apache/spark/pull/10399#discussion_r57026000
--- 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 --
What do we do in other cases? (i.e. does an `Int` get converted to a
`Long`?).
I think that ideally we would eliminate run-time type reflection for
performance, but we can't do that here since we need to handle multiple types
of decimal.
---
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]