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

Add Expr->String for WindowFunction #10243

Merged
merged 1 commit into from
Apr 26, 2024
Merged

Add Expr->String for WindowFunction #10243

merged 1 commit into from
Apr 26, 2024

Conversation

yyy1000
Copy link
Contributor

@yyy1000 yyy1000 commented Apr 26, 2024

Which issue does this PR close?

Related #9726 .

Rationale for this change

What changes are included in this PR?

  1. Support filter field in aggregate function
  2. Support WindowFunction Expr->String

Are these changes tested?

Are there any user-facing changes?

@github-actions github-actions bot added sql SQL Planner logical-expr Logical plan and expressions labels Apr 26, 2024
Copy link
Contributor Author

@yyy1000 yyy1000 left a comment

Choose a reason for hiding this comment

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

order_by field in aggregate function and window function is not available now. I plan to do it later.

Comment on lines +401 to +412
fn function_args_to_sql(&self, args: &[Expr]) -> Result<Vec<ast::FunctionArg>> {
args.iter()
.map(|e| {
if matches!(e, Expr::Wildcard { qualifier: None }) {
Ok(ast::FunctionArg::Unnamed(ast::FunctionArgExpr::Wildcard))
} else {
self.expr_to_sql(e)
.map(|e| ast::FunctionArg::Unnamed(ast::FunctionArgExpr::Expr(e)))
}
})
.collect::<Result<Vec<_>>>()
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Extract a common function for convert function args to ast.

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thank you @yyy1000 -- this looks very nice to me.

cc @devinjdangelo

}
})
.collect::<Result<Vec<_>>>()?;
let func_name = agg.func_def.name();
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

order_by: None,
null_treatment: None,
}),
"COUNT(*) FILTER (WHERE true)",
Copy link
Contributor

Choose a reason for hiding this comment

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

nice

@yyy1000
Copy link
Contributor Author

yyy1000 commented Apr 26, 2024

Thanks for your review~ @alamb
I was busy with school things last several weeks but now I'm available again. 😆

@alamb
Copy link
Contributor

alamb commented Apr 26, 2024

Thanks for your review~ @alamb I was busy with school things last several weeks but now I'm available again. 😆

It is great to have you back!

@alamb alamb merged commit cdbd964 into apache:main Apr 26, 2024
23 checks passed
@yyy1000 yyy1000 deleted the port_window branch April 26, 2024 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
logical-expr Logical plan and expressions sql SQL Planner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants