Skip to content

Instantly share code, notes, and snippets.

@potix2
Last active August 29, 2015 14:23
Show Gist options
  • Save potix2/b290aebb53fde9d4f64a to your computer and use it in GitHub Desktop.
Save potix2/b290aebb53fde9d4f64a to your computer and use it in GitHub Desktop.
import org.apache.spark.sql.SQLContext
def etl(sqlContext: SQLContext, source: String, destination: String): Unit = {
val df = sqlContext.read.format("com.databricks.spark.csv").option("header", "true").load(source)
df.select("year", "model").write.format("com.databricks.spark.csv").save(destination)
}
// etl(new SQLContext(sc), "cars.csv", "newcars.csv")
val testContext = TestSQLContext()
val testDF = TestDataFrame()
testContext.load("cars.csv") returns testDF
etl(textContext, "cars.csv", "newcars.csv")
there was one(testDF).select("year", "model")
//there was one(testDF).save("newcars.csv")
@potix2
Copy link
Author

potix2 commented Jun 25, 2015

これはテストする意味ないね。。。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment