Skip to content

Feature Request: Support DATE_PART syntax as an alias for EXTRACT #62631

@murphyatwork

Description

@murphyatwork

Description
StarRocks currently supports the EXTRACT(field FROM source) function to obtain specific parts of a date or timestamp. However, many users coming from PostgreSQL or Snowflake are more familiar with the DATE_PART(field, source) syntax.

To improve compatibility and ease migration, StarRocks should support DATE_PART as a syntax sugar (alias) for EXTRACT.

Proposal

  • Add support for DATE_PART('field', datetime_expr)
  • Semantics should be identical to EXTRACT(field FROM datetime_expr)
  • Supported fields: year, month, day, hour, minute, second, dow, doy, etc.

Examples

SELECT DATE_PART('year', TIMESTAMP '2025-09-02 13:45:00');
-- Expected: 2025

SELECT DATE_PART('dow', TIMESTAMP '2025-09-02 13:45:00');
-- Expected: 2

Use Cases

  • Simplifies migration from PostgreSQL/Snowflake.
  • Improves developer experience by allowing familiar syntax.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions