spark-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mich Talebzadeh <mich.talebza...@gmail.com>
Subject Re: How to retrieve multiple columns values (in one row) to variables in Spark Scala method
Date Sat, 06 Apr 2019 15:45:46 GMT
Thanks Ayan!

Much appreciated your help.

Regards,


Dr Mich Talebzadeh



LinkedIn * https://www.linkedin.com/profile/view?id=AAEAAAAWh2gBxianrbJd6zP6AcPCCdOABUrV8Pw
<https://www.linkedin.com/profile/view?id=AAEAAAAWh2gBxianrbJd6zP6AcPCCdOABUrV8Pw>*



http://talebzadehmich.wordpress.com


*Disclaimer:* Use it at your own risk. Any and all responsibility for any
loss, damage or destruction of data or any other property which may arise
from relying on this email's technical content is explicitly disclaimed.
The author will in no case be liable for any monetary damages arising from
such loss, damage or destruction.




On Fri, 5 Apr 2019 at 23:56, ayan guha <guha.ayan@gmail.com> wrote:

> Try like this:
>
> val primitiveDS = spark.sql("select 1.2 avg ,2.3
> stddev").collect().apply(0)
> val arr = Array(primitiveDS.getDecimal(0), primitiveDS.getDecimal(1))
>
> primitiveDS: org.apache.spark.sql.Row = [1.2,2.3] arr:
> Array[java.math.BigDecimal] = Array(1.2, 2.3)
>

Mime
View raw message