How to use Column.isin in Java?

后端 未结 2 1523
旧巷少年郎
旧巷少年郎 2020-12-03 22:42

I\'m trying to filter a Spark DataFrame using a list in Java.

java.util.List selected = ....;
DataFrame result = df.filter(df.col(\"something\").         


        
相关标签:
2条回答
  • 2020-12-03 23:29

    Use stream method as follows:

    df.filter(col("something").isin(selected.stream().toArray(String[]::new))))
    
    0 讨论(0)
  • 2020-12-03 23:34

    A bit shorter version would be:

    df.filter(col("something").isin(selected.toArray()));
    
    0 讨论(0)
提交回复
热议问题