Objects using SparkSession

Among the Spark 2.x, and in fact SQLContext HiveContext obsolete, the opposite is the use of the sql function SparkSession object to manipulate SQL statement. Before using this function executes SQL statements need to call createOrReplaceTempView DataFrame registered a temporary table, so the key is to first convert the RDD into DataFrame. In fact, the actual declared Spark

type DataFrame = Dataset[Row]

So, DataFrame is Dataset [Row] alias. RDD is to provide for low-level API, and DataFrame / Dataset provide for high-level API (such as SQL for the occasion for structured data).

Here are some examples of Spark SQL program.

An example of a: SparkSQLExam.scala

Guess you like

Origin www.cnblogs.com/55hyh/p/11932901.html