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

}

@Test
public void testQuarter() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

These tests verify the Java methods directly, but they do not exercise SQL registration, overload resolution, type inference, or runtime invocation.
Could we add an end-to-end SQL test for them there?

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

2 participants