定义 collection 作为 string 如果在配置单元查询中使用: Example: ``` val df=Seq((1,"a"),(2,"b"),(3,"c")).toDF("id","name") spark.sql("select * from tmp").show() df.createOrReplaceTempView("tmp") spark.sql("select * from tmp").show() val st=""""a","b"""" spark.sql(s"select * from tmp where name in ($st)").show() //Output: //+---+----+ //| id|name| //+---+----+ //| 1| a| //| 2| b| //+---+----+
1条答案
按热度按时间qxgroojn1#
定义
collection
作为string
如果在配置单元查询中使用:Example:
```val df=Seq((1,"a"),(2,"b"),(3,"c")).toDF("id","name")
spark.sql("select * from tmp").show()
df.createOrReplaceTempView("tmp")
spark.sql("select * from tmp").show()
val st=""""a","b""""
spark.sql(s"select * from tmp where name in ($st)").show()
//Output:
//+---+----+
//| id|name|
//+---+----+
//| 1| a|
//| 2| b|
//+---+----+