SparkSQL是否支持类似类型查询,我正在寻找类似的等价项
select * from table where name like '%Bush'
是的,您可以用常规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|
+----+---+