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

Window exec uses framing iterator and support agg functions in windows #746

Merged
merged 3 commits into from
Jan 21, 2022

Conversation

max-hoffman
Copy link
Contributor

@max-hoffman max-hoffman commented Jan 20, 2022

plan.Window is converted into new WindowIter backed by the framing setup.
Codegen unary agg function nodes, including executable and unit testing
harness. Rewrite window aggregation functions for framing.
More unit tests that will make it easier to debug WindowBlock/Iter
Doc comments for the new WindowIter exec stack.

Copy link
Member

@zachmu zachmu left a comment

Choose a reason for hiding this comment

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

Overall very good work, definitely an improvement in organization and functionality.

My one overall comment is that this needs a some package-level docs explaining what the various abstractions are supposed to do and how they fit together. This doesn't need to be long, just a couple sentences for each type and a paragraph or two on the big picture. But I still have trouble keeping what each of these abstractions do straight in my head as I read this code.

optgen/cmd/optgen/main.go Show resolved Hide resolved
sql/expression/function/aggregation/common.go Outdated Show resolved Hide resolved
sql/expression/function/aggregation/common.go Show resolved Hide resolved
}

func (a *unaryAggBase) Resolved() bool {
if _, ok := a.Child.(*expression.Star); ok {
Copy link
Member

Choose a reason for hiding this comment

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

What's with this? Star is by definition not resolved (should get expanded by some other analyzer rule)

If you want to do it this way, create another Star expression, like AggregateStar to differentiate

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is copied from the old count code, if we have a resolver it doesn't catch these. should i make an issue?

sql/expression/function/aggregation/common.go Outdated Show resolved Hide resolved
sql/plan/window.go Outdated Show resolved Hide resolved
sql/plan/window.go Outdated Show resolved Hide resolved
@@ -83,6 +85,29 @@ func (w *Window) String() string {
return sb.String()
}

func (w *Window) PartitionId() (uint64, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Relatively expensive. If this gets called a lot, should probably cache the result.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

how? if i'm keeping a cache of strings to int64 shouldn't i just use the strings as the ID?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i see what you mean now, fixed

@max-hoffman max-hoffman changed the title Refactor windows to use framing setup, enable agg functions in windows Window exec uses framing iterator and support agg functions in windows Jan 21, 2022
plan.Window is converted into new WindowIter backed by the framing setup.
Codegen unary agg function nodes, including executable and unit testing
harness. Rewrite window aggregation functions for framing.
More unit tests that will make it easier to debug WindowBlock/Iter
Doc comments for the new WindowIter exec stack.
@max-hoffman max-hoffman merged commit 8ddb338 into main Jan 21, 2022
@max-hoffman max-hoffman deleted the max/window-refactor branch January 21, 2022 18:55
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.

None yet

2 participants