Trying the examples of Spark SQL, they seem to work well except when expressions are needed:
scala> val teenagers = people.where('age >= 10).where('age <= 19).select('name)
<console>:23: error: value >= is not a member of Symbol
val teenagers = people.where('age >= 10).where('age <= 19).select('name)
scala> val teenagers = people.select('name)
<console>:23: error: type mismatch;
found : Symbol
required: org.apache.spark.sql.catalyst.expressions.Expression
val teenagers = people.select('name)
It seems that I need an import not documented.
If I bulk importing everything
import org.apache.spark.sql.catalyst.analysis._
import org.apache.spark.sql.catalyst.dsl._
import org.apache.spark.sql.catalyst.errors._
import org.apache.spark.sql.catalyst.expressions._
import org.apache.spark.sql.catalyst.plans.logical._
import org.apache.spark.sql.catalyst.rules._
import org.apache.spark.sql.catalyst.types._
import org.apache.spark.sql.catalyst.util._
import org.apache.spark.sql.execution
import org.apache.spark.sql.hive._
EDIT: ... and
val sqlContext = new org.apache.spark.sql.SQLContext(sc)
import sqlContext._
it works.
There is an implicit conversion you are lacking.
val sqlContext: org.apache.spark.sql.SQLContext = ???
import sqlContext._
That has however changed in the recent (and supported) versions of Spark.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With