Skip to content

Add the date functions QUARTER / DAY_OF_YEAR #791

Description

@Leomrlin

What & why

The date folder udf/table/date/ has 23 functions (Year, Month, Day,
WeekOfYear, …) but is missing QUARTER (1–4) and DAY_OF_YEAR (1–366) —
both heavily used in time-based analytics.

日期函数目录已有 23 个,但缺 QUARTER(季度 1-4)和 DAY_OF_YEAR(一年中的第几天,
1-366),这两个在时间维度分析里很常用。

The task

  • quarter(date) → 1–4
  • day_of_year(date) → 1–366

Where to look

  1. udf/table/date/WeekOfYear.java is the closest pattern ("turn a date into an
    integer"); add Quarter.java and DayOfYear.java alongside it.
  2. Register in BuildInSqlFunctionTable.java.
  3. Test leap years and year boundaries (e.g. 12/31, 1/1) plus null.

Done when

  • Two functions implemented and registered
  • Leap year and start/end-of-year boundaries correct
  • Reuses the existing date-parsing approach (don't reinvent it)
  • Tests pass

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions