Give the error code first
def main(args: Array[String]): Unit = {
//Create SparkConf() And Set AppName
SparkSession.builder()
.appName("Spark Sql basic example")
.config("spark.some.config.option", "some-value")
.getOrCreate()
//import implicit DF,DS
import spark.implicits._ //Here the spark appears in red and cannot be imported
}
Solution: give sparksession. Builder a corresponding variable value, which is spark
The spark here is not something under a package, but the variable value corresponding to our sparksession. Builder(). Here is the correct way to write it
def main(args: Array[String]): Unit = {
//Create SparkConf() And Set AppName
val spark= SparkSession.builder()
.appName("Spark Sql basic example")
.config("spark.some.config.option", "some-value")
.getOrCreate()
//import implicit DF,DS
import spark.implicits._
}