spark-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jacek Laskowski <ja...@japila.pl>
Subject [SQL] Why does (0 to 9).toDF("num").as[String] work?
Date Sat, 13 Aug 2016 20:17:54 GMT
Hi,

Just ran into it and can't explain why it works. Please help me understand it.

Q1: Why can I `as[String]` with Ints? Is this type safe?

scala> (0 to 9).toDF("num").as[String]
res12: org.apache.spark.sql.Dataset[String] = [num: int]

Q2: Why can I map over strings even though there are really ints?

scala> (0 to 9).toDF("num").as[String].map(_.toUpperCase)
res11: org.apache.spark.sql.Dataset[String] = [value: string]

Why are the two lines possible?

Pozdrawiam,
Jacek Laskowski
----
https://medium.com/@jaceklaskowski/
Mastering Apache Spark 2.0 http://bit.ly/mastering-apache-spark
Follow me at https://twitter.com/jaceklaskowski

---------------------------------------------------------------------
To unsubscribe e-mail: user-unsubscribe@spark.apache.org


Mime
View raw message