struct-type-encoder (homepage)

Deriving Spark DataFrame schemas from case classes

@BenFradet / (0)

struct-type-encoder derives instances of `StructType` from your case class automatically:
import ste.StructTypeEncoder
import ste.StructTypeEncoder._
val derived = spark
  .read
  .schema(StructTypeEncoder[MyCaseClass].encode)
  .json("/some/dir/*.json")
  .as[MyCaseClass]

No inference, no boilerplate!


Tags

  • 1|sql

How to

Include this package in your Spark Applications using:

spark-shell, pyspark, or spark-submit

> $SPARK_HOME/bin/spark-shell --packages com.github.benfradet:struct-type-encoder_2.11:0.1.0

sbt

In your sbt build file, add:

libraryDependencies += "com.github.benfradet" % "struct-type-encoder_2.11" % "0.1.0"

Maven

In your pom.xml, add:
<dependencies>
  <!-- list of dependencies -->
  <dependency>
    <groupId>com.github.benfradet</groupId>
    <artifactId>struct-type-encoder_2.11</artifactId>
    <version>0.1.0</version>
  </dependency>
</dependencies>

Releases

Version: 0.1.0 ( f0e73d | zip | jar ) / Date: 2017-07-10 / License: Apache-2.0 / Scala version: 2.11