Running HiveQL queries using Apache Spark™ SQL
Spark SQL supports queries written using HiveQL, a SQL-like language that produces queries that are converted to Spark jobs.
HiveQL is more mature and supports more complex queries than Spark SQL.
To construct a HiveQL query, first create a new HiveContext
instance, and then submit the queries by calling the sql
method on the HiveContext
instance.
See the Hive Language Manual for the full syntax of HiveQL.
Creating indexes with |
Procedure
-
Start the Spark shell.
bin/dse spark
-
Use the provided
HiveContext
instancesqlContext
to create a new query in HiveQL by calling thesql
method on thesqlContext
object.scala> val results = sqlContext.sql("SELECT * FROM my_keyspace.my_table")