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

feature: support REGEXP_REPLACE function #4944

Merged
merged 5 commits into from
Apr 20, 2022

Conversation

nange
Copy link
Contributor

@nange nange commented Apr 19, 2022

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

Summary

  • Support REGEXP_REPLACE function
  • Make the logic of arguments validating more reasonable and consistent for regexp_* functions (the same as snowflake)
  • Mini fix for how-to-write-scalar-functions doc

Changelog

  • New Feature
  • Improvement
  • Documentation

Related Issues

Fixes #3057

@vercel
Copy link

vercel bot commented Apr 19, 2022

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

1 Ignored Deployment
Name Status Preview Updated
databend ⬜️ Ignored (Inspect) Apr 20, 2022 at 0:31AM (UTC)

@nange
Copy link
Contributor Author

nange commented Apr 19, 2022

/review @sundy-li

@mergify
Copy link
Contributor

mergify bot commented Apr 19, 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.

@databend-bot
Copy link
Member

Take the reviewer to sundy-li

@mergify mergify bot added pr-feature this PR introduces a new feature to the codebase pr-improvement labels Apr 19, 2022
@@ -100,6 +100,10 @@ impl Function for RegexpLikeFunction {
mt,
)?))
}

fn passthrough_constant(&self) -> bool {
Copy link
Member

Choose a reason for hiding this comment

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

I think it's incorrect.

passthrough_constant only works when all arguments are constant. So it's ok to check_get ConstColumn.

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, fixed. And I also have simplified some of the code for regexp_like function.

@@ -69,7 +74,7 @@ impl Function for RegexpInStrFunction {
}

fn return_type(&self) -> DataTypePtr {
u64::to_data_type()
NullableType::arc(u64::to_data_type())
Copy link
Member

Choose a reason for hiding this comment

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

Why do we return NullableType and disable_passthrough_null?

It makes the code more complex.

Copy link
Member

Choose a reason for hiding this comment

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

Oh, it's same as snowflake did.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. If we enable the passthrough_null , we can't know original of the argument(eg. pos) is 0 or null in eval function.

@BohuTANG BohuTANG merged commit 97f8e83 into databendlabs:main Apr 20, 2022
@BohuTANG BohuTANG mentioned this pull request May 12, 2022
55 tasks
@nange nange deleted the feat/regexp_replace_function branch July 27, 2023 11:27
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.

REGEXP_REPLACE() | Replace substrings matching regular expression
4 participants