Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert a table into a Spark Dataframe

In Spark SQL, a dataframe can be queried as a table using this:

sqlContext.registerDataFrameAsTable(df, "mytable")

Assuming what I have is mytable, how can I get or access this as a DataFrame?

like image 795
oikonomiyaki Avatar asked Aug 28 '16 12:08

oikonomiyaki


1 Answers

The cleanest way:

df = sqlContext.table("mytable")

Documentation

like image 121
Igor Tavares Avatar answered Oct 06 '22 16:10

Igor Tavares