Skip to content

[SPARK-51554][SQL] Add the time_trunc() function #51547

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

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

uros-db
Copy link
Contributor

@uros-db uros-db commented Jul 18, 2025

What changes were proposed in this pull request?

Implement the time_trunc function, which returns time truncated to the unit specified in unit.

Syntax

time_trunc(unit, expr)

Arguments

  • unit: A STRING literal. Can be: HOUR, MINUTE, SECOND, MILLISECOND, MICROSECOND.
  • expr: A TIME with a valid time format.

Returns
A TIME(n) with n matching that of expr.

Why are the changes needed?

Users will be able to truncate time values by specified units.

Does this PR introduce any user-facing change?

Yes, this PR introduces a new expression.

How was this patch tested?

New unit tests for time truncation, catalyst expression level unit tests with & without codegen, e2e SQL tests / golden files in both ANSI and non-ANSI modes.

Was this patch authored or co-authored using generative AI tooling?

No.

@github-actions github-actions bot added the SQL label Jul 18, 2025
@uros-db uros-db changed the title [WIP][SPARK-51554][SQL] Add the time_trunc() function [SPARK-51554][SQL] Add the time_trunc() function Jul 18, 2025
@uros-db
Copy link
Contributor Author

uros-db commented Jul 18, 2025

@MaxGekk Please review.

@uros-db
Copy link
Contributor Author

uros-db commented Jul 18, 2025

CI failures don't look related to my changes. I'm merging latest master now to see if that fixes it.

Otherwise, this PR is ready for review @MaxGekk.

@uros-db uros-db requested a review from MaxGekk July 21, 2025 09:05
@the-sakthi
Copy link
Member

I'm sorry but the original PR: #50607 is still active with active review comments. The new revision catering to the comments was pushed before this PR.

I informed about the same on the related JIRA as well. I would like to see that PR through if y'all don't mind.
cc: @MaxGekk , @uros-db

@uros-db uros-db requested a review from MaxGekk July 22, 2025 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants