+---+---+---+
|cnt|_c1|grp|
+---+---+---+
|  1| 31|  0|
|  1| 31|  1|
|  1|  4|  0|
|  1|  4|  1|
|  1| 42|  0|
|  1| 42|  1|
|  1| 15|  0|
|  1| 15|  1|
|  1| 26|  0|
|  1| 26|  1|
|  1| 37|  0|
|  1| 10|  0|
|  1| 37|  1|
|  1| 10|  1|
|  1| 48|  0|
|  1| 21|  0|
|  1| 48|  1|
|  1| 21|  1|
|  1| 32|  0|
|  1| 32|  1|
+---+---+---+

​

On Thu, Jul 9, 2015 at 11:54 AM, ayan guha <[email protected]> wrote:

> Can you please post result of show()?
> On 10 Jul 2015 01:00, "Yana Kadiyska" <[email protected]> wrote:
>
>> Hi folks, I just re-wrote a query from using UNION ALL to use "with
>> rollup" and I'm seeing some unexpected behavior. I'll open a JIRA if needed
>> but wanted to check if this is user error. Here is my code:
>>
>> case class KeyValue(key: Int, value: String)
>> val df = sc.parallelize(1 to 50).map(i=>KeyValue(i, i.toString)).toDF
>>
>> df.registerTempTable("foo")
>>
>> sqlContext.sql(“select count(*) as cnt, value as key,GROUPING__ID from foo 
>> group by value with rollup”).show(100)
>>
>>
>> sqlContext.sql(“select count(*) as cnt, key % 100 as key,GROUPING__ID from 
>> foo group by key%100 with rollup”).show(100)
>>
>> ​
>>
>> Grouping by value does the right thing, I get one group 0 with the
>> overall count. But grouping by expression (key%100) produces weird results
>> -- appears that group 1 results are replicated as group 0. Am I doing
>> something wrong or is this a bug?
>>
>

Reply via email to