[
https://issues.apache.org/jira/browse/SPARK-54630?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Vinod KC resolved SPARK-54630.
------------------------------
Resolution: Implemented
Implemented in https://issues.apache.org/jira/browse/SPARK-56594
> Add timestamp_bucket function for temporal bucketing with configurable
> alignment
> --------------------------------------------------------------------------------
>
> Key: SPARK-54630
> URL: https://issues.apache.org/jira/browse/SPARK-54630
> Project: Spark
> Issue Type: Improvement
> Components: SQL
> Affects Versions: 3.5.0, 4.0.0
> Reporter: Vinod KC
> Priority: Major
> Labels: pull-request-available
>
> Add a new timestamp_bucket function to group temporal data into fixed-width
> intervals with configurable bucket alignment. This function addresses the
> need for arbitrary interval bucketing beyond calendar-based units.
> Currently, Spark SQL lacks a flexible way to bucket timestamps into arbitrary
> intervals with custom alignment:
> Limitations of existing functions:
> * date_trunc: Only supports fixed calendar units (year, month, week, day,
> hour, minute, second)
> * No support for custom bucket alignment (e.g., Monday-aligned weeks, fiscal
> periods, shift schedules)
> Common use cases that are difficult today:
> # Bucketing by arbitrary intervals (e.g., 15 minutes, 6 hours, 90 days)
> # Aligning buckets to business schedules (e.g., weekly reports starting
> Monday)
> # Grouping sensor data or logs into custom time windows
> # Time-series analysis with non-standard intervals
>
> Add `timestamp_bucket(bucket_width, timestamp[, origin])` function with the
> following characteristics:
> Function Signature:
> {code:java}
> timestamp_bucket(bucket_width INTERVAL DAY TO SECOND, timestamp
> DATE|TIMESTAMP|TIMESTAMP_NTZ, origin TIMESTAMP) -> TIMESTAMP{code}
> *Comparison with Other Databases*
> {_}PostgreSQL{_}:
> date_bin(interval, timestamp, origin)
> {_}TimescaleDB{_}:
> time_bucket(interval, timestamp, origin)
> The proposed function provides similar functionality to PostgreSQL's date_bin
> and TimescaleDB's time_bucket
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]