I have registered a temporary table with Spark SQL, as described in [this section]:
people.registerTempTable("people")
// I can run queries on it all right.
val teenagers = sqlContext.sql("SELECT name FROM people WHERE age >= 13 AND age <= 19")
Now I want to access this table remotely through JDBC. I start up the Thrift Server as described in [this other section].
./sbin/start-thriftserver.sh --master spark://same-master-as-above:7077
But the table is not visible.
0: jdbc:hive2://localhost:10000> show tables;
+---------+
| result |
+---------+
+---------+
No rows selected (2.216 seconds)
I guess this is because the table is "temporary" (i.e. tied to the lifetime of the SqlContext
object). But how do I make non-temporary tables?
I can see Hive tables through the Thrift Server, but I don't see how I could expose an RDD like this. I've found a comment that suggests I cannot.
Or should I run the Thrift Server in my application with my own SqlContext
? Almost all classes around it are private
, and this code is not in Maven Central (as far as I see). Am I supposed to use HiveThriftServer2.startWithContext
? It's undocumented and @DeveloperApi
, but might work.