For this, I can give you a SQL solution:
joined data.registerTempTable('j')
Res=ssc.sql('select col1,col2, count(1) counter, min(col3) minimum,
sum(case when endrscp>100 then 1 else 0 end test from j'
Let me know if this works.
On 26 May 2015 23:47, "Masf" <[email protected]> wrote:
> Hi
> I don't know how it works. For example:
>
> val result = joinedData.groupBy("col1","col2").agg(
> count(lit(1)).as("counter"),
> min(col3).as("minimum"),
> sum("case when endrscp> 100 then 1 else 0 end").as("test")
> )
>
> How can I do it?
>
> Thanks!!!!
> Regards.
> Miguel.
>
> On Tue, May 26, 2015 at 12:35 AM, ayan guha <[email protected]> wrote:
>
>> Case when col2>100 then 1 else col2 end
>> On 26 May 2015 00:25, "Masf" <[email protected]> wrote:
>>
>>> Hi.
>>>
>>> In a dataframe, How can I execution a conditional sentence in a
>>> aggregation. For example, Can I translate this SQL statement to DataFrame?:
>>>
>>> SELECT name, SUM(IF table.col2 > 100 THEN 1 ELSE table.col1)
>>> FROM table
>>> GROUP BY name
>>>
>>> Thanks!!!!
>>> --
>>> Regards.
>>> Miguel
>>>
>>
>
>
> --
>
>
> Saludos.
> Miguel Ángel
>