There are two ways to create context in Spark SQL:

SqlContext:

scala> import org.apache.spark.sql._
scala> var sqlContext = new SQLContext(sc)

HiveContext:

scala> import org.apache.spark.sql.hive._
scala> val hc = new HiveContext(sc)

Though most of the code examples you see use SqlContext, you should always use HiveContext. HiveContext is a superset of SqlContext, so it can do what SQLContext can do and much more. You do not have to connect to Hive to use HiveContext.

posted on 2016-03-17 16:23  回家的流浪者  阅读(547)  评论(0编辑  收藏  举报