Skip to content
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

planner: support window function #8630

Merged
merged 29 commits into from
Jan 3, 2019
Merged

planner: support window function #8630

merged 29 commits into from
Jan 3, 2019

Conversation

alivxxx
Copy link
Contributor

@alivxxx alivxxx commented Dec 10, 2018

What problem does this PR solve?

Support the window function in planner.

What is changed and how it works?

Add logical and physical plan operator for window function. It resolves the name in window function before projection, and build the window funtion after processing the having clause. For partition by and order by clause in window functioin, it adds sort operator as it's child.
The named window and frame clause will be processed in next PR.

Check List

Tests

  • Unit test

Code changes

  • Has exported function/method change

Side effects

  • None

Related changes

PTAL @zz-jason @winoros @XuHuaiyu @eurekaka


This change is Reviewable

@alivxxx alivxxx added sig/planner SIG: Planner type/enhancement The issue or PR belongs to an enhancement. labels Dec 10, 2018
@@ -0,0 +1,29 @@
// Copyright 2018 PingCAP, Inc.
Copy link
Member

Choose a reason for hiding this comment

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

should it belong to aggregation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Change the package name to udf or something else?

Copy link
Member

Choose a reason for hiding this comment

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

No need to, window function is also a kind of aggregate function.

Copy link
Member

Choose a reason for hiding this comment

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

But its behavior is quite different with normal aggregate function since it won't make the rows grouped into one though there's OVER clause.
I think they should be in the same level not superior-subordinate.

planner/core/logical_plan_builder.go Outdated Show resolved Hide resolved
planner/core/logical_plan_builder.go Outdated Show resolved Hide resolved
@@ -0,0 +1,29 @@
// Copyright 2018 PingCAP, Inc.
Copy link
Member

Choose a reason for hiding this comment

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

No need to, window function is also a kind of aggregate function.

planner/core/initialize.go Outdated Show resolved Hide resolved
planner/core/initialize.go Outdated Show resolved Hide resolved
planner/core/logical_plans.go Outdated Show resolved Hide resolved
planner/core/exhaust_physical_plans.go Outdated Show resolved Hide resolved
@alivxxx
Copy link
Contributor Author

alivxxx commented Dec 13, 2018

PTAL @winoros @zz-jason

planner/core/explain.go Show resolved Hide resolved
planner/core/logical_plans.go Show resolved Hide resolved
planner/core/expression_rewriter.go Show resolved Hide resolved
planner/core/exhaust_physical_plans.go Outdated Show resolved Hide resolved
planner/core/explain.go Show resolved Hide resolved
planner/core/logical_plan_builder.go Outdated Show resolved Hide resolved
planner/core/logical_plan_builder.go Show resolved Hide resolved
planner/core/logical_plan_builder.go Show resolved Hide resolved
planner/core/logical_plan_builder.go Outdated Show resolved Hide resolved
planner/core/logical_plan_builder.go Show resolved Hide resolved
planner/core/logical_plans.go Outdated Show resolved Hide resolved
@alivxxx
Copy link
Contributor Author

alivxxx commented Dec 28, 2018

PTAL @zz-jason @winoros

planner/core/logical_plan_builder.go Outdated Show resolved Hide resolved
planner/core/logical_plan_builder.go Show resolved Hide resolved
planner/core/stringer.go Outdated Show resolved Hide resolved
Copy link
Member

@zz-jason zz-jason left a comment

Choose a reason for hiding this comment

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

LGTM

planner/core/logical_plan_builder.go Show resolved Hide resolved
planner/core/logical_plan_builder.go Show resolved Hide resolved
planner/core/logical_plan_test.go Outdated Show resolved Hide resolved
@alivxxx
Copy link
Contributor Author

alivxxx commented Jan 2, 2019

PTAL @winoros

planner/core/logical_plan_builder.go Show resolved Hide resolved
planner/core/logical_plan_builder.go Show resolved Hide resolved
planner/core/logical_plan_builder.go Show resolved Hide resolved
planner/core/stats.go Show resolved Hide resolved
planner/core/rule_column_pruning.go Show resolved Hide resolved
eurekaka
eurekaka previously approved these changes Jan 3, 2019
Copy link
Contributor

@eurekaka eurekaka left a comment

Choose a reason for hiding this comment

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

LGTM

@eurekaka eurekaka added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Jan 3, 2019
@alivxxx
Copy link
Contributor Author

alivxxx commented Jan 3, 2019

/run-all-tests

@alivxxx
Copy link
Contributor Author

alivxxx commented Jan 3, 2019

/run-unit-test

@alivxxx
Copy link
Contributor Author

alivxxx commented Jan 3, 2019

I updated the parser, PTAL @eurekaka

@alivxxx alivxxx merged commit 91cdbf2 into pingcap:master Jan 3, 2019
@alivxxx alivxxx deleted the window branch January 3, 2019 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/planner SIG: Planner status/LGT2 Indicates that a PR has LGTM 2. type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants