Scala's Seq:* equivalent in java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Scala's Seq:* equivalent in java

onmstester onmstester
I could not find how to pass a list to isin() filter in java, something like this could be done with scala:

val ids = Array(1,2)
df.filter(df("id").isin(ids:_*)).show
But in java everything that converts java list to scala Seq fails with unsupported literal type exception:
JavaConversions.asScalaBuffer(list).toSeq()
JavaConverters.asScalaIteratorConverter(list.iterator()).asScala().toSeq().seq()

Sent using Zoho Mail



Reply | Threaded
Open this post in threaded view
|

Re: Scala's Seq:* equivalent in java

Koert Kuipers
Isn't _* varargs? So you should be able to use Java array?

On Tue, May 15, 2018, 06:29 onmstester onmstester <[hidden email]> wrote:
I could not find how to pass a list to isin() filter in java, something like this could be done with scala:

val ids = Array(1,2)
df.filter(df("id").isin(ids:_*)).show
But in java everything that converts java list to scala Seq fails with unsupported literal type exception:
JavaConversions.asScalaBuffer(list).toSeq()
JavaConverters.asScalaIteratorConverter(list.iterator()).asScala().toSeq().seq()

Sent using Zoho Mail




On May 15, 2018 06:29, "onmstester onmstester" <[hidden email]> wrote:
I could not find how to pass a list to isin() filter in java, something like this could be done with scala:

val ids = Array(1,2)
df.filter(df("id").isin(ids:_*)).show
But in java everything that converts java list to scala Seq fails with unsupported literal type exception:
JavaConversions.asScalaBuffer(list).toSeq()
JavaConverters.asScalaIteratorConverter(list.iterator()).asScala().toSeq().seq()

Sent using Zoho Mail