0

I'm new with zeppelin, but it look like interesting. I'd like to do some visualization with cassandra's data reading with spark within zeppelin. But I can't do it, yet!

This is my code:

import org.apache.spark.sql.cassandra._
import org.apache.spark.sql
val createDDL = """CREATE TEMPORARY VIEW keyspaces9
 USING org.apache.spark.sql.cassandra
 OPTIONS (
 table "foehis",
 keyspace "tfm",
 pushdown "true")"""
spark.sql(createDDL) 
spark.sql("SELECT hoclic,hodtac,hohrac,hotpac FROM keyspaces").show

And I get:

res41: org.apache.spark.sql.DataFrame = []
+------+--------+------+------+
|hoclic|  hodtac|hohrac|hotpac|
+------+--------+------+------+
|  1011|10180619|   510|  ENPR|
|  1011|20140427|   800|  ANDE|
|  1011|20140427|   800|  ANDE|
|  1011|20170522|  1100|  ANDE|
|  1011|20170522|  1100|  ANDE|
....

But I don't have the ability to make a viz

How do I convert that data into a table for zeppelin?

Skiel
  • 307
  • 1
  • 12
  • Looks like this would answer your question: https://stackoverflow.com/questions/44946620/how-can-i-pretty-print-a-data-frame-in-zeppelin-spark-scala – Moran Aug 09 '18 at 23:35

1 Answers1

1

Register the DataFrame as a Table using df.registerTempTable. In your case, register 'keyspaces' dataframe as table and then you can execute the SQL queries on the table and create visualizations.

Sample code: enter image description here

Lakshman Battini
  • 1,842
  • 11
  • 25