Created
September 20, 2016 20:15
-
-
Save mkwatson/ecdafc47720c74b2bee7586c2e2bf300 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
case class Person(name: String, age: Long, ttl: Long) | |
val caseClassDF = Seq(Person("Andy", 32, 5000000), Person("Mark", 27, 1000000)).toDF() | |
caseClassDF.show() | |
// +----+---+-------+ | |
// |name|age| ttl| | |
// +----+---+-------+ | |
// |Andy| 32|5000000| | |
// |Mark| 27|1000000| | |
// +----+---+-------+ | |
// With Table: | |
// CREATE TABLE IF NOT EXISTS test.person ( | |
// name BIGINT, | |
// age BIGINT, | |
// PRIMARY KEY (name, age) | |
// ) | |
caseClassDF.write | |
.format("org.apache.spark.sql.cassandra") | |
.options(Map( "table" -> "words_copy", "keyspace" -> "test", "ttl_column" -> "ttl")) | |
.save() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment