How to create SparkSession from existing SparkContext

前端 未结 6 998
时光取名叫无心
时光取名叫无心 2020-12-30 20:47

I have a Spark application which using Spark 2.0 new API with SparkSession. I am building this application on top of the another application which is using

6条回答
  •  旧时难觅i
    2020-12-30 21:10

    Like in the above example you cannot create because SparkSession's constructor is private Instead you can create a SQLContext using the SparkContext, and later get the sparksession from the sqlcontext like this

    val sqlContext=new SQLContext(sparkContext);
    val spark=sqlContext.sparkSession
    

    Hope this helps

提交回复
热议问题