To pass a list to a variadic function you can use the type ascription :_*

For example:

val longList = Seq[Expression]("a", "b", ...)
table("src").where('key in (longList: _*))

Also, note that I had to explicitly specify Expression as the type
parameter of Seq to ensure that the compiler converts "a" and "b" into
Spark SQL expressions.




On Thu, Aug 28, 2014 at 11:52 PM, Jaonary Rabarisoa <jaon...@gmail.com>
wrote:

> ok, but what if I have a long list do I need to hard code like this every
> element of my list of is there a function that translate a list into a
> tuple ?
>
>
> On Fri, Aug 29, 2014 at 3:24 AM, Michael Armbrust <mich...@databricks.com>
> wrote:
>
>> You don't need the Seq, as in is a variadic function.
>>
>> personTable.where('name in ("foo", "bar"))
>>
>>
>>
>> On Thu, Aug 28, 2014 at 3:09 AM, Jaonary Rabarisoa <jaon...@gmail.com>
>> wrote:
>>
>>> Hi all,
>>>
>>> What is the expression that I should use with spark sql DSL if I need to
>>> retreive
>>> data with a field in a given set.
>>> For example :
>>>
>>> I have the following schema
>>>
>>> case class Person(name: String, age: Int)
>>>
>>> And I need to do something like :
>>>
>>> personTable.where('name in Seq("foo", "bar")) ?
>>>
>>>
>>> Cheers.
>>>
>>>
>>> Jaonary
>>>
>>
>>
>

Reply via email to