GitHub user yhuai opened a pull request:

    https://github.com/apache/spark/pull/1735

    [SQL] Set outputPartitioning of BroadcastHashJoin correctly.

    I think we will not generate the plan triggering this bug at this moment. 
But, let me explain it...
    
    Right now, we are using `left.outputPartitioning` as the 
`outputPartitioning` of a `BroadcastHashJoin`. We may have a wrong physical 
plan for cases like...
    ```sql
    SELECT l.key, count(*)
    FROM (SELECT key, count(*) as cnt
          FROM src
          GROUP BY key) l // This is buildPlan
    JOIN r // This is the streamedPlan
    ON (l.cnt = r.value)
    GROUP BY l.key
    ```
    Let's say we have a `BroadcastHashJoin` on `l` and `r`. For this case, we 
will pick `l`'s `outputPartitioning` for the `outputPartitioning`of the 
`BroadcastHashJoin` on `l` and `r`. Also, because the last `GROUP BY` is using 
`l.key` as the key, we will not introduce an `Exchange` for this aggregation. 
However, `r`'s outputPartitioning may not match the required distribution of 
the last `GROUP BY` and we fail to group data correctly.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/yhuai/spark BroadcastHashJoin

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/1735.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #1735
    
----
commit 96d9cb3fa6963b5c8154da9b9c3ff9b780fa1456
Author: Yin Huai <[email protected]>
Date:   2014-08-02T05:43:35Z

    Set outputPartitioning correctly.

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to