Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/apache-spark/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Scala ApacheSparkDataFrame:df.where()带有Java:List属性_Scala_Apache Spark_Filter_Dataframe_Where - Fatal编程技术网

Scala ApacheSparkDataFrame:df.where()带有Java:List属性

Scala ApacheSparkDataFrame:df.where()带有Java:List属性,scala,apache-spark,filter,dataframe,where,Scala,Apache Spark,Filter,Dataframe,Where,假设您有这样一个df: a b 1 1 1 2 1 3 2 1 2 2 2 3 你想实现一个通用的。where functionality; 如何按列表进行筛选 val l1:List[Int] = List (1,2) df.where($"b" === l1:_*) // does not work 或者你可以问这样的问题: df.where($"a" === l1:_* && $"b" === l1:_*) 如果我没说错的话,你想在语义

假设您有这样一个df:

a b  
1 1  
1 2  
1 3  
2 1  
2 2  
2 3  
你想实现一个通用的。where functionality; 如何按列表进行筛选

val l1:List[Int] = List (1,2)  
df.where($"b" === l1:_*) // does not work
或者你可以问这样的问题:

df.where($"a" === l1:_* && $"b" === l1:_*)

如果我没说错的话,你想在语义学上:

df.where($"b" isin (l1: _*)).show()
+---+---+ 
|  a|  b| 
+---+---+ 
|  1|  1| 
|  1|  2| 
|  2|  1| 
|  2|  2| 
+---+---+ 


如果我没说错的话,你想在语义学上:

df.where($"b" isin (l1: _*)).show()
+---+---+ 
|  a|  b| 
+---+---+ 
|  1|  1| 
|  1|  2| 
|  2|  1| 
|  2|  2| 
+---+---+