How to use Column.isin with list?

后端 未结 5 1586
眼角桃花
眼角桃花 2020-11-29 06:00
val items = List(\"a\", \"b\", \"c\")

sqlContext.sql(\"select c1 from table\")
          .filter($\"c1\".isin(items))
          .collect
          .foreach(println)         


        
5条回答
  •  春和景丽
    2020-11-29 06:23

    As Tomalak has mentioned it :

    isin(java.lang.Object... list)
    A boolean expression that is evaluated to true if the value 
    of this expression is contained by the evaluated values of the arguments.
    

    Therefore, you just could fix this making the following change :

    val items = List("a", "b", "c").map(c => s""""$c"""")
    

提交回复
热议问题