Created
May 30, 2019 15:57
-
-
Save afranzi/2d5f82c09476d9d7d13ecdfbf1d9edce to your computer and use it in GitHub Desktop.
This file contains hidden or 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
trait SparkWriter { | |
def write(df: DataFrame, mode: WriteMode = Overwrite): Unit | |
} | |
class SparkJsonWriter(path: String, partitions: Int = 1) extends SparkWriter { | |
def write(df: DataFrame, mode: WriteMode = Overwrite): Unit = { | |
df | |
.coalesce(partitions) | |
.write | |
.mode(mode) | |
.json(path) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment