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

Support Date32 for date_trunc function #12603

Merged
merged 1 commit into from
Sep 24, 2024

Conversation

goldmedal
Copy link
Contributor

Which issue does this PR close?

Closes #12602 .

Rationale for this change

What changes are included in this PR?

date_trunc accepts Date32 now.

Are these changes tested?

yes

Are there any user-facing changes?

no

@github-actions github-actions bot added sqllogictest SQL Logic Tests (.slt) functions labels Sep 24, 2024
@@ -123,7 +123,9 @@ impl ScalarUDFImpl for DateTruncFunc {

fn return_type(&self, arg_types: &[DataType]) -> Result<DataType> {
match &arg_types[1] {
Timestamp(Nanosecond, None) | Utf8 | Null => Ok(Timestamp(Nanosecond, None)),
Timestamp(Nanosecond, None) | Utf8 | DataType::Date32 | 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 also tried to support Date64 but got many type coercion issues between Timestamp and Date64. I think we should handle them in another PR if needed.

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.

Looks good to me -- thank you for the contribution @goldmedal

@alamb alamb merged commit fbfd7d4 into apache:main Sep 24, 2024
24 checks passed
@goldmedal goldmedal deleted the feature/12602-date-trunc-date branch September 25, 2024 01:33
@goldmedal
Copy link
Contributor Author

Thanks @alamb 🙇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
functions sqllogictest SQL Logic Tests (.slt)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DATE_TRUNC supports Date type
2 participants