Reputation: 7951
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?
Upvotes: 20
Views: 51195
Reputation: 18022
Well you can query it and save the result into a variable. Check that SQLContext
's method sql returns a DataFrame
.
df = sqlContext.sql("SELECT * FROM mytable")
Upvotes: 19