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

feat: Window func #5401

Merged
merged 33 commits into from Jun 9, 2022
Merged

feat: Window func #5401

merged 33 commits into from Jun 9, 2022

Conversation

doki23
Copy link
Contributor

@doki23 doki23 commented May 16, 2022

I hereby agree to the terms of the CLA available at: https://databend.rs/dev/policies/cla/

Summary

impl it partially including

  1. aggr function
  2. const rows frame
  3. const range frame
  4. only works in the old scheduler framework now

Changelog

  • New Feature
    aggregate window function

Related Issues

Closes #4653

@vercel
Copy link

vercel bot commented May 16, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Updated
databend ⬜️ Ignored (Inspect) Jun 9, 2022 at 1:49AM (UTC)

@mergify
Copy link
Contributor

mergify bot commented May 16, 2022

Thanks for the contribution!
I have applied any labels matching special text in your PR Changelog.

Please review the labels and make any necessary changes.

@mergify mergify bot added the pr-feature this PR introduces a new feature to the codebase label May 16, 2022
@Xuanwo
Copy link
Member

Xuanwo commented May 16, 2022

@mergify update

@mergify
Copy link
Contributor

mergify bot commented May 16, 2022

update

✅ Branch has been successfully updated

@@ -0,0 +1,5 @@
mod window_frame;
Copy link
Member

@BohuTANG BohuTANG May 16, 2022

Choose a reason for hiding this comment

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

Hmm, need a license header to make the lint happy :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I'll fix it then. And this pr's far away from ready for reviews 😂.

Copy link
Member

Choose a reason for hiding this comment

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

A great start! Welcome asking at discussions if you have any questions 💌

@doki23 doki23 marked this pull request as ready for review June 7, 2022 07:22
@doki23 doki23 changed the title (WIP)Window func feat: Window func Jun 7, 2022
@doki23
Copy link
Contributor Author

doki23 commented Jun 7, 2022

Sorry for the late update, because I'm too busy recently.
It's ready for review now.

#[derive(
Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Hash, serde::Serialize, serde::Deserialize,
)]
pub struct WindowFrame {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Code in this file is mainly copied from another open source project -- apache/arrow-datafusion. And I'm not sure whether it's proper or if I should add some description on the top of it.

Copy link
Member

@sundy-li sundy-li Jun 7, 2022

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Please attach their license header in this file with a clear statement, for example:

https://github.com/apache/arrow-datafusion/blob/master/datafusion/core/src/prelude.rs#L1-L16

And add descriptions include:

  • Original Project
  • Link to commits

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 think it's ok. Do we have stateless tests for this pr? Like: https://github.com/datafuselabs/databend/blob/49252766894f3bb5f5d4767037142cb1b10d92bc/tests/suites/0_stateless/03_dml/03_0003_select_group_by.sql

Thanks for the remind and I'll add some stateless tests then.

@doki23 doki23 requested review from BohuTANG and Xuanwo June 7, 2022 07:36
@sundy-li
Copy link
Member

sundy-li commented Jun 8, 2022

Impressive pr, I'll take time to review it.

@sundy-li sundy-li self-requested a review June 8, 2022 03:41
@BohuTANG BohuTANG requested review from zhang2014 and removed request for BohuTANG June 8, 2022 09:52
Copy link
Member

@zhang2014 zhang2014 left a comment

Choose a reason for hiding this comment

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

👍 Look good to me. BTW: need implement window function in new processor.

@BohuTANG
Copy link
Member

BohuTANG commented Jun 8, 2022

@mergify update

@mergify
Copy link
Contributor

mergify bot commented Jun 8, 2022

update

✅ Branch has been successfully updated

Copy link
Member

@BohuTANG BohuTANG left a comment

Choose a reason for hiding this comment

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

👍

@doki23
Copy link
Contributor Author

doki23 commented Jun 8, 2022

👍 Look good to me. BTW: need implement window function in new processor.

Yes, I'll create a follow-up issue and also make some optimizations about performance.

@mergify mergify bot merged commit f7e7b1c into datafuselabs:main Jun 9, 2022
Copy link
Member

@sundy-li sundy-li left a comment

Choose a reason for hiding this comment

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

Left some comments, these can be improved in another pr.

arguments.push(ColumnWithField::new(Arc::clone(arg_column), arg_field));
}

let function = if !AggregateFunctionFactory::instance().check(op) {
Copy link
Member

Choose a reason for hiding this comment

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

we can have a function field in this transformer.

})
.collect::<Vec<_>>();

let window_col = Series::concat(&window_col_per_tuple).unwrap();
Copy link
Member

Choose a reason for hiding this comment

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

unwrap could be replaced by Result.

.collect::<Vec<ColumnRef>>()
})
.map(|args| {
let place = arena.alloc_layout(func.state_layout());
Copy link
Member

Choose a reason for hiding this comment

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

we should call drop_states to destroy the inner allocation as PartialAggregator did.

@BohuTANG
Copy link
Member

Ping @soyeric128 for documentation.

@soyeric128
Copy link
Collaborator

Hi @BohuTANG @doki23

Could you pls help confirm?

Thanks.

@doki23
Copy link
Contributor Author

doki23 commented Jun 28, 2022

Hi @BohuTANG @doki23

Could you pls help confirm?

Thanks.

We support all aggregate functions(any function that impl trait AggregateFunction) but have not yet implemented any non-aggr functions.

@soyeric128
Copy link
Collaborator

Hi @BohuTANG @doki23
Could you pls help confirm?

Thanks.

We support all aggregate functions(any function that impl trait AggregateFunction) but have not yet implemented any non-aggr functions.

Thanks for reply.
Pls review this PR for doc updates: #6445

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need-review pr-feature this PR introduces a new feature to the codebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: Window Functions Support
7 participants