-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathSimpleExample.java
More file actions
28 lines (24 loc) · 932 Bytes
/
SimpleExample.java
File metadata and controls
28 lines (24 loc) · 932 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package org.apache.cassandra.spark;
import org.apache.cassandra.spark.sparksql.LocalDataSource;
import org.apache.spark.SparkConf;
import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.Row;
import org.apache.spark.sql.SparkSession;
public class SimpleExample
{
public static void main(final String[] args)
{
final SparkSession spark = SparkSession.builder()
.config(new SparkConf().set("spark.master", "local"))
.getOrCreate();
final Dataset<Row> df = spark.read().format(LocalDataSource.class.getName())
.option("keyspace", "test")
.option("createStmt", "CREATE TABLE IF NOT EXISTS test.basic_test (a bigint PRIMARY KEY, b bigint, c bigint);")
.option("dirs", args[0])
.load();
for (Row row : df.collectAsList())
{
System.out.println("Row: " + row);
}
}
}