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(query): add func date_format and str_to_date and str_to_timestamp #11442

Merged
merged 1 commit into from
May 14, 2023

Conversation

TCeason
Copy link
Collaborator

@TCeason TCeason commented May 14, 2023

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

Summary

support function:

date_format(Timestamp, String) :: String NULL
date_format(Timestamp NULL, String NULL) :: String NULL

str_to_date(String, String) :: Date NULL
str_to_date(String NULL, String NULL) :: Date NULL
str_to_timestamp(String, String) :: Timestamp NULL
str_to_timestamp(String NULL, String NULL) :: Timestamp NULL

Note

  • If use str_to_timestamp , the string must contains timezone. Because we need to unique date and time. If not contains timezone will return null.

Closes #11125

@vercel
Copy link

vercel bot commented May 14, 2023

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

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
databend ⬜️ Ignored (Inspect) May 14, 2023 9:05am

@mergify mergify bot added the pr-feature this PR introduces a new feature to the codebase label May 14, 2023
@BohuTANG

This comment was marked as outdated.

@BohuTANG BohuTANG merged commit 1030ec3 into databendlabs:main May 14, 2023
@BohuTANG
Copy link
Member

These functions requires additional documentation. Thanks! cc @soyeric128

We already have an powerful date format function in place. cc @wubx

output.push_null();
} else {
match (std::str::from_utf8(date), std::str::from_utf8(format)) {
(Ok(date), Ok(format)) => {
Copy link
Member

Choose a reason for hiding this comment

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

why not throw the error?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Refer to MySQL behavior here. Return null directly if there is any invalid

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 we should not follow MySQL's behavior, we should throw if any error happens.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think we should not follow MySQL's behavior, we should throw if any error happens.

Modify in this pr: #11455

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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: hope to support like mysql date_format and str_to_date fuction
4 participants