spark.sql vs SqlContext

后端 未结 4 1996
盖世英雄少女心
盖世英雄少女心 2021-01-20 16:04

I have used SQL in Spark, in this example:

results = spark.sql(\"select * from ventas\")

where ventas is a dataframe, previosuly cataloged

4条回答
  •  情歌与酒
    2021-01-20 16:58

    Before Spark 2.x SQLContext was build with help of SparkContext but after Spark 2.x SparkSession was introduced which have the functionality of HiveContext and SQLContect both.So no need of creating SQLContext separatly.

       **before Spark2.x**
       sCont = SparkContext()
       sqlCont = SQLContext(sCont)
    
       **after Spark 2.x:** 
       spark = SparkSession()
    
    

提交回复
热议问题