GitHub user dongjoon-hyun opened a pull request:

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

    [SPARK-16994][SQL] PushDownPredicate should not ignore limits.

    ## What changes were proposed in this pull request?
    
    Currently, `filter` and `limit` are illegally permuted because 
`PushDownPredicate` optimizer pushes `filters` through `limit`. This PR fixes 
that.
    
    **Reported Error Scenario**
    ```
    scala> spark.createDataset(1 to 100).limit(10).filter($"value" % 10 === 
0).explain
    == Physical Plan ==
    CollectLimit 10
    +- *Filter ((value#875 % 10) = 0)
       +- LocalTableScan [value#875]
    
    scala> spark.createDataset(1 to 100).limit(10).filter($"value" % 10 === 
0).collect
    res23: Array[Int] = Array(10, 20, 30, 40, 50, 60, 70, 80, 90, 100)
    ```
    
    **After**
    ```
    scala> spark.createDataset(1 to 100).limit(10).filter($"value" % 10 === 
0).explain
    == Physical Plan ==
    *Filter ((value#1 % 10) = 0)
    +- *GlobalLimit 10
       +- Exchange SinglePartition
          +- *LocalLimit 10
             +- LocalTableScan [value#1]
    
    scala> spark.createDataset(1 to 100).limit(10).filter($"value" % 10 === 
0).collect
    res1: Array[Int] = Array(10)
    ```
    
    ## How was this patch tested?
    
    Pass the Jenkins with a new test case.

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

    $ git pull https://github.com/dongjoon-hyun/spark SPARK-16994

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

    https://github.com/apache/spark/pull/14583.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 #14583
    
----
commit aa84c8e71f8eb636b021ce5f573c8d0694fc19ce
Author: Dongjoon Hyun <[email protected]>
Date:   2016-08-10T16:57:26Z

    [SPARK-16994][SQL] PushDownPredicate should not ignore limits.

----


---
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