Last active
March 21, 2016 16:21
-
-
Save zero323/ef66ef6ad25d6fe9b501 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scalaVersion := "2.11.7" | |
libraryDependencies ++= Seq( | |
"org.apache.spark" %% "spark-core" % "1.6.1", | |
"org.apache.spark" %% "spark-sql" % "1.6.1" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.spark._ | |
import org.apache.spark.sql._ | |
import scala.util.Try | |
case class Dummy() | |
object App { | |
def main(args: Array[String]) { | |
val sc = new SparkContext("local", "foo", new SparkConf()) | |
val sqlContext = new SQLContext(sc) | |
val df = sqlContext.read.json(sc.parallelize(Seq("""{"a": [1, 2, 3]}"""))) | |
val optionA = Option(df.first.getAs[Dummy]("a")) // No exception | |
require(Try(optionA.map(identity)).isFailure) | |
sc.stop() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment