Github user marmbrus commented on the pull request:
https://github.com/apache/spark/pull/2850#issuecomment-60537184
Thanks for working on this! In order for the BigDecimals to work we are
going to need to do some conversions as well. This is because the expected
internal representation of BigDecimal is the scala class, not the java one.
Consider the following test case:
```scala
assert(
javaSqlCtx.sql("SELECT bigDecimalField + bigDecimalField FROM
allTypes").collect.head.row ===
Seq(new java.math.BigDecimal(0)))
```
Which will throw
```
[info] org.apache.spark.SparkException: Job aborted due to stage failure:
Task 1 in stage 2.0 failed 1 times, most recent failure: Lost task 1.0 in stage
2.0 (TID 5, localhost): java.lang.ClassCastException: java.math.BigDecimal
cannot be cast to scala.math.BigDecimal
[info]
scala.math.Numeric$BigDecimalIsFractional$.plus(Numeric.scala:182)
[info]
org.apache.spark.sql.catalyst.expressions.Add$$anonfun$eval$3.apply(arithmetic.scala:72)
```
I think we'll need to do something similar to
[convertToCatalyst](https://github.com/apache/spark/blob/master/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/ScalaReflection.scala#L35)
but for Java.
---
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]