spark-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <Saif.A.Ell...@wellsfargo.com>
Subject RE: Scala: How to match a java object????
Date Tue, 18 Aug 2015 19:59:49 GMT
Hi, thank you for further assistance

you can reproduce this by simply running

5 match { case java.math.BigDecimal => 2 }

In my personal case, I am applying a map acton to a Seq[Any], so the elements inside are of
type any, to which I need to apply a proper .asInstanceOf[WhoYouShouldBe].

Saif

From: William Briggs [mailto:wrbriggs@gmail.com]
Sent: Tuesday, August 18, 2015 4:46 PM
To: Ellafi, Saif A.; user@spark.apache.org
Subject: Re: Scala: How to match a java object????


Could you share your pattern matching expression that is failing?

On Tue, Aug 18, 2015, 3:38 PM  <Saif.A.Ellafi@wellsfargo.com<mailto:Saif.A.Ellafi@wellsfargo.com>>
wrote:
Hi all,

I am trying to run a spark job, in which I receive java.math.BigDecimal objects, instead of
the scala equivalents, and I am trying to convert them into Doubles.
If I try to match-case this object class, I get: “error: object java.math.BigDecimal is
not a value”

How could I get around matching java objects? I would like to avoid a multiple try-catch on
ClassCastExceptions for all my checks.

Thank you,
Saif

Mime
View raw message