SQLContext implies

I study spark and scala. I am well versed in java, but not much in scala. I go through the spark tutorial and stumbled upon the following line of code that was not explained:

val sqlContext = new org.apache.spark.sql.SQLContext(sc)
import sqlContext.implicits._

( scis an instance of SparkContext)

I know the concepts behind scala implicits (at least I think I know). Can someone explain to me what exactly is meant by the expression importabove? What is implicitsattached to the instance sqlContextwhen it is created and how? Are these implications defined in the SQLContext class?

EDIT The following seems to work for me as well (fresh code):

val sqlc = new SQLContext(sc)
import sqlContext.implicits._

This code is a little higher. What is sqlContext and where is it defined?

+4
1

ScalaDoc: sqlContext.implicits "(Scala -) , Scala Scala DataFrames."

Spark:

// this is used to implicitly convert an RDD to a DataFrame.
import sqlContext.implicits._

, .toDF() , sqlContext.implicits:

val airports = sc.makeRDD(Source.fromFile(airportsPath).getLines().drop(1).toSeq, 1)
    .map(s => s.replaceAll("\"", "").split(","))
    .map(a => Airport(a(0), a(1), a(2), a(3), a(4), a(5), a(6)))
    .toDF()

sqlContext, ? SQLContext?

, implicits SqlContext, SQLImplicits.scala. -, :

  • RDD DataFrameHolder, rdd.toDf().
  • Encoder, " JVM T Spark SQL".
+3

Source: https://habr.com/ru/post/1625649/


All Articles