SparkSQL是否支持类型查询,我正在寻找像:
这样的等价物 select * from table where name like '%Bush'
答案 0 :(得分:3)
是的,确实如此,您可以使用常规SQL执行此类查询。例如:
val nadf = sqlContext.createDataFrame( Seq(
( "Alice", 10),
( "Alice", 20),
( "Bob", 10),
( "Bobo", 20)
)).toDF("name", "age")
nadf.registerTempTable("nadf")
产生如下结果:
scala> sqlContext.sql("""select * from nadf where name like "%Bob"""").show()
+----+---+
|name|age|
+----+---+
| Bob| 10|
+----+---+
scala> sqlContext.sql("""select * from nadf where name like "%Bob%"""").show()
+----+---+
|name|age|
+----+---+
| Bob| 10|
|Bobo| 20|
+----+---+