我想使用基于SQL语言的功能集成SQL来筛选schemaRDD。 例如,我想运行
SELECT name FROM people WHERE name LIKE '%AHSAN%' AND name regexp '^[A-Z]{20}$'
我怎样才能在people.where使用这些SQL函数()?
参考:
对于语言集成SQL,我下面给出的例子在这里 。
val sqlContext = new org.apache.spark.sql.SQLContext(sc)
import sqlContext._
val people: RDD[Person] = ... // An RDD of case class objects, from the first example.
// The following is the same as 'SELECT name FROM people WHERE age >= 10 AND age <= 19'
val teenagers = people.where('age >= 10).where('age <= 19).select('name)
teenagers.map(t => "Name: " + t(0)).collect().foreach(println)
提前致谢!