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

Update generate_series example to use NOW()::timestamp since timestamptz is not supported for generate_series #2637

Merged
merged 4 commits into from
Sep 26, 2024

Conversation

kwannoel
Copy link
Contributor

@kwannoel kwannoel commented Sep 25, 2024

Description

generate_series only works with timestamp, not timestamptz. The example in our doc fails due to this. Perhaps some regression? Not sure if NOW() changed to return timestamptz instead of timestamp.

dev=> create materialized view m1 as SELECT time::timestamptz FROM generate_series(
  '2020-01-01 00:00:00',
  now(),
  interval '1 hour'
) t(time);
ERROR:  Failed to run the query

Caused by:
  function generate_series(unknown, timestamp with time zone, interval) does not exist


dev=> create materialized view m1 as SELECT * FROM generate_series(
  '2020-01-01 00:00:00'::timestamptz,
  now(),
  interval '1 hour'
);
NOTICE:  Your session timezone is UTC. It was used in the interpretation of timestamps and dates in your query. If this is unintended, change your timezone to match that of your data's with `set timezone = [timezone]` or rewrite your query with an explicit timezone conversion, e.g. with `AT TIME ZONE`.

CREATE_MATERIALIZED_VIEW

Related code PR

Related doc issue

Resolve

Rendered preview

Checklist

  • I have checked the doc site preview, and the updated parts look good.
  • I have acquired the approval from the owner (and optionally the reviewers) of the code PR and at least one tech writer (emile-00, hengm3467, & WanYixian).

@kwannoel kwannoel changed the title Update sql-function-set-returning.md Update generate_series example to use NOW()::timestamp since timestamptz is not supported for generate_series Sep 25, 2024
Copy link

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-2637.d2fbku9n2b6wde.amplifyapp.com

@stdrc
Copy link
Contributor

stdrc commented Sep 25, 2024

Streaming generate_series with now() as end doesn't go through the normal function binding path. The example in doc is streaming query, not batch query, though this is indeed a bit confusing.

@kwannoel
Copy link
Contributor Author

Streaming generate_series with now() as end doesn't go through the normal function binding path. The example in doc is streaming query, not batch query, though this is indeed a bit confusing.

dev=> create materialized view m1 as SELECT time::timestamptz FROM generate_series(
  '2020-01-01 00:00:00',
  now(),
  interval '1 hour'
) t(time);
ERROR:  Failed to run the query

Caused by:
  function generate_series(unknown, timestamp with time zone, interval) does not exist

Is it a regression then? 🤔

@stdrc
Copy link
Contributor

stdrc commented Sep 25, 2024

Streaming generate_series with now() as end doesn't go through the normal function binding path. The example in doc is streaming query, not batch query, though this is indeed a bit confusing.

dev=> create materialized view m1 as SELECT time::timestamptz FROM generate_series(
  '2020-01-01 00:00:00',
  now(),
  interval '1 hour'
) t(time);
ERROR:  Failed to run the query

Caused by:
  function generate_series(unknown, timestamp with time zone, interval) does not exist

Is it a regression then? 🤔

Interesting... Let me fix this tmr🤣

@kwannoel
Copy link
Contributor Author

Streaming generate_series with now() as end doesn't go through the normal function binding path. The example in doc is streaming query, not batch query, though this is indeed a bit confusing.

dev=> create materialized view m1 as SELECT time::timestamptz FROM generate_series(
  '2020-01-01 00:00:00',
  now(),
  interval '1 hour'
) t(time);
ERROR:  Failed to run the query

Caused by:
  function generate_series(unknown, timestamp with time zone, interval) does not exist

Is it a regression then? 🤔

Interesting... Let me fix this tmr🤣

Okay no rush, you can take a look first. I updated the doc accoridngly. Thanks for clarifying it's in streaming, I missed that part.

@kwannoel kwannoel merged commit cd9c4ac into main Sep 26, 2024
3 checks passed
@kwannoel kwannoel deleted the kwannoel-patch-2 branch September 26, 2024 02:33
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.

3 participants