-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Open
Labels
Description
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.