Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new date_bin_wallclock SQL functions #5691

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

sanderson
Copy link
Collaborator

@sanderson sanderson commented Nov 27, 2024

Related to https://github.com/influxdata/influxdb_iox/issues/12681

Adds the following SQL functions to the Serverless, Dedicated, and Clustered docs:

  • date_bin_wallclock
  • date_bin_wallclock_gapfill

  • Rebased/mergeable


Use `date_bin_wallclock_gapfill` with [`interpolate`](/influxdb/clustered/reference/sql/functions/misc/#interpolate)
or [`locf`](/influxdb/clustered/reference/sql/functions/misc/#locf) to
[fill gaps in data]()
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing URL


### Time zone shifts

Many regions use time zone shifts (such as Daylight Saving Time (DST) and British
Copy link

Choose a reason for hiding this comment

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

"Daylight Saving Time" and "British Summer Time" aren't equivalents. DST refers to the general concept of adjusting the local time to make the most of the daylight hours. BST is a time zone offset identifier. I think this should be reworded a little to express that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@mhilton Thanks. Is there a generalized term you use in the UK to represent the 1 hour seasonal offset? Is it just Daylight Savings Time? In the US, we have the general "DST," but we also have timezone-specific offset identifiers (Pacific Standard Time (PST) vs Pacific Daylight Time (PDT)).

Copy link

Choose a reason for hiding this comment

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

Yes it's very similar, but in the UK we only have to worry about one time-zone so they can be used haphazardly. The concept is known as "Daylight Saving Time" which changes the timezone from "GMT" to "BST".

UTC offset of the input timestamp.

```sql
date_bin_wallclock(interval, expression[, origin])
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
date_bin_wallclock(interval, expression[, origin])
date_bin_wallclock(interval, expression[, origin_timestamp])

The arguments defined below uses origin_timestamp. To keep wording consistent, maybe changing the word to origin_timestamp here, or changing the word to origin below?

The output timestamp uses the time zone from this time expression.
- **origin_timestamp**: Starting point used to determine bin boundaries.
This must be a "wall clock" timestamp (no time zone).
_Default is the Unix epoch._
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be good to highlight a caveat:

Using an origin and interval such that there are bins within a discontinuity, but which do not align with the point at which the discontinuity occurs, can produce unexpected results. For example, considering the following query:

SELECT date_bin_wallclock(INTERVAL '1 hour', tz('2020-10-25T02:29:00+01:00', 'Europe/Paris'), '1970-01-01T00:30:00') AT TIME ZONE 'UTC';

The result is:

2020-10-24T23:30:00Z

However, the result of a nearly identical query:

SELECT date_bin_wallclock(INTERVAL '1 hour', tz('2020-10-25T02:30:00+01:00', 'Europe/Paris'), '1970-01-01T00:30:00') AT TIME ZONE 'UTC';

is:

2020-10-25T01:30:00Z

That is, timestamps only one minute apart are placed into bins that are two hours apart, despite the expected interval being one hour. Care should be taken to avoid such scenarios.

Copy link

Choose a reason for hiding this comment

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

In general advice to try and stay away from the discontinuities is probably sensible.

Copy link
Contributor

@jstirnaman jstirnaman left a comment

Choose a reason for hiding this comment

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

👍 , pending other reviewer suggestions.

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.

4 participants