尝试 Spark SQL 的示例,它们似乎运行良好,除非需要表达式:
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)
看来我需要一个没有记录的导入。
如果我批量导入所有内容
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._
编辑:...和
val sqlContext = new org.apache.spark.sql.SQLContext(sc)
import sqlContext._
有用。