Skip to content

Conversation

@skambha
Copy link
Contributor

@skambha skambha commented Mar 3, 2016

What changes were proposed in this pull request?

This patch does the following:
I) Adds a new optimizer rule collapsesorts that does the following if global is same for the adjacent sorts.
a) Collapse adjacent sorts and keep the last sort
b) Collapse adjacent sorts if there is a project or a limit or a filter in between and keep the last sort.

II) A new test suite CollapseSortsSuite is added with tests.
Also note, one of the _testcase (test("collapsesorts: test collapsesorts in sort <- limit <- sort scenario") ) _does not compare with expected plan because of the unapply in Limit will actually remove the LocalLimit from the plan. Hence the test just checks that the collapsesorts rule was exercised by checking for the number of Sort in the plan.

How was this patch tested?

A)
Following test suites were run and the lint checking was done. No new test failures:
build/sbt -Phive hive/test
build/sbt sql/test
build/sbt catalyst/test
dev/lint-scala

B) A new test suite CollapseSortsSuite is added with new tests to exercise the collapsesorts rule.

@AmplabJenkins
Copy link

Can one of the admins verify this patch?

* either a) The sorts are adjacent or b) In between two Sort nodes, there is a Filter or
* a Project or a Limit
*/
object CollapseSorts extends Rule[LogicalPlan] {
Copy link
Contributor

Choose a reason for hiding this comment

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

as it is, i'm not sure how useful this rule is.

I think what would be useful is to have an EliminateSort rule, that can actually eliminate the more useful cases.

Copy link
Contributor

Choose a reason for hiding this comment

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

And if we do it, we probably want to do it based on some output constraint of a plan

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.

3 participants