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 funciton coalesce #5922

Merged
merged 13 commits into from
Jun 22, 2022
Merged

Add funciton coalesce #5922

merged 13 commits into from
Jun 22, 2022

Conversation

TianLangStudio
Copy link
Contributor

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

Summary

Add funciton coalesce WIP

Changelog

  • New Feature

Related Issues

Fixes #5768

@vercel
Copy link

vercel bot commented Jun 12, 2022

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

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

@mergify
Copy link
Contributor

mergify bot commented Jun 12, 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 Jun 12, 2022
@sundy-li
Copy link
Member

@TianLangStudio
Refer to : https://github.com/ClickHouse/ClickHouse/blob/70b51133c11bad4afb905d53e08ccf2956c19f68/src/Functions/coalesce.cpp#L92-L98

We can transform coalesce expression inside the type_checker (in the new planner)

@TianLangStudio
Copy link
Contributor Author

image
image

@TianLangStudio
Copy link
Contributor Author

@sundy-li Thanks. As you know I am a newbie. I thought it didn't support this way until I saw the function NULLIF last week. I will commit later and may not have time to add tests and documents recently. Maybe you can review the function coalesce first.
It may not be the same as the reference you gave.
Nice weekend!

@@ -586,6 +588,39 @@ impl<'a> TypeChecker<'a> {
.await?
}

Expr::Coalesce { span, exprs } => {
// Rewrite COALESCE(expr1, expr2, ...) to IF(IS_NOT_NULL(expr1), expr1, expr2)
let resolve_args = exprs.iter().rev().fold(
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 filter exprs to remove Literal::Null

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'll add the filter later.

@sundy-li
Copy link
Member

@TianLangStudio Thanks for your contribution, I'll continue this task based on your commits.

@sundy-li sundy-li marked this pull request as ready for review June 21, 2022 11:53
@sundy-li sundy-li requested review from leiysky and b41sh June 21, 2022 11:53
@b41sh
Copy link
Member

b41sh commented Jun 22, 2022

/LGTM

@sundy-li sundy-li merged commit c0d05f1 into datafuselabs:main Jun 22, 2022
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
Development

Successfully merging this pull request may close these issues.

COALESCE function
5 participants