Skip to content

feat: add date functions QUARTER and DAY_OF_YEAR#814

Open
YinZiBenRun wants to merge 1 commit into
apache:masterfrom
YinZiBenRun:feature/add-date-functions-quarter-dayofyear
Open

feat: add date functions QUARTER and DAY_OF_YEAR#814
YinZiBenRun wants to merge 1 commit into
apache:masterfrom
YinZiBenRun:feature/add-date-functions-quarter-dayofyear

Conversation

@YinZiBenRun

Copy link
Copy Markdown

Add two new date UDFs:

  • quarter(date): returns the quarter of the year (1-4)
  • day_of_year(date): returns the day of the year (1-366)

Both follow the existing WeekOfYear pattern using Joda-Time. Registered in BuildInSqlFunctionTable.
Tests cover quarter boundaries, leap years, year boundaries, and null inputs.

Closes #791

What changes were proposed in this pull request?

Add two new date UDFs:

  • quarter(date): returns the quarter of the year (1-4), e.g. quarter('2020-06-05') = 2
  • day_of_year(date): returns the day of the year (1-366), e.g. day_of_year('2020-12-31') = 366

Both follow the existing WeekOfYear pattern using Joda-Time DateTime and DateTimeFormatter.
Registered in BuildInSqlFunctionTable.java.

How was this PR tested?

  • [√] Tests have Added for the changes
  • Production environment verified

Add two new date UDFs:
- quarter(date): returns the quarter of the year (1-4)
- day_of_year(date): returns the day of the year (1-366)

Both follow the existing WeekOfYear pattern using Joda-Time.
Registered in BuildInSqlFunctionTable.
Tests cover quarter boundaries, leap years, year boundaries, and null inputs.

Closes apache#791
@YinZiBenRun

Copy link
Copy Markdown
Author

#791

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add the date functions QUARTER / DAY_OF_YEAR

1 participant