Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed

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

wants to merge 2 commits into from

Conversation

dongjoon-hyun
Copy link
Member

@dongjoon-hyun dongjoon-hyun commented Aug 10, 2016

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.

@@ -1988,6 +1988,11 @@ class SQLQuerySuite extends QueryTest with SharedSQLContext {
}
}

test("SPARK-16994: filter should not be pushed down into local limit") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Writing an end-to-end test case is not very helpful here.

You can write a new test case in the related optimizer rule.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @gatorsmile .

@SparkQA
Copy link

SparkQA commented Aug 10, 2016

Test build #63548 has finished for PR 14583 at commit aa84c8e.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Aug 11, 2016

Test build #63581 has finished for PR 14583 at commit d23d348.

  • This patch fails PySpark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@dongjoon-hyun
Copy link
Member Author

Retest this please

@SparkQA
Copy link

SparkQA commented Aug 11, 2016

Test build #63589 has finished for PR 14583 at commit d23d348.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Aug 13, 2016

Test build #63732 has finished for PR 14583 at commit 91fb344.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@dongjoon-hyun
Copy link
Member Author

Hi, @rxin .
Could you review this PR about PushDownPredicate?

@SparkQA
Copy link

SparkQA commented Aug 16, 2016

Test build #63854 has finished for PR 14583 at commit c09fdc6.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Aug 18, 2016

Test build #63986 has finished for PR 14583 at commit eea0dfe.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@rxin
Copy link
Contributor

rxin commented Aug 19, 2016

I'm fixing this differently here: #14713

@dongjoon-hyun
Copy link
Member Author

Okay. Thanks, @rxin.

@dongjoon-hyun dongjoon-hyun deleted the SPARK-16994 branch January 7, 2019 07:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants