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 generate_series for timestampTZ values #64887

Merged
merged 1 commit into from
May 9, 2021

Conversation

oeph
Copy link
Contributor

@oeph oeph commented May 7, 2021

This change adds generate_series(timestamptz, timestamptz, interval) as it is also supported by postgres

Fixes #64850

@blathers-crl
Copy link

blathers-crl bot commented May 7, 2021

Thank you for contributing to CockroachDB. Please ensure you have followed the guidelines for creating a PR.

My owl senses detect your PR is good for review. Please keep an eye out for any test failures in CI.

I have added a few people who may be able to assist in reviewing:

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan.

@blathers-crl blathers-crl bot added O-community Originated from the community X-blathers-triaged blathers was able to find an owner labels May 7, 2021
@blathers-crl blathers-crl bot requested a review from RaduBerinde May 7, 2021 18:50
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@RaduBerinde
Copy link
Member

Thanks for the contribution!

If you can, it would be great to also add a (timestamp, timestamp, interval) version, so we don't have to come back to it later.

Could you add a test like the one below (inspired from #64722)?

set timezone='Europe/Bucharest';
select '2020-10-25 00:00'::TIMESTAMPTZ + (i::text || ' hour')::interval from generate_series(0, 24) AS g(i);
select t from generate_series('2020-10-25 00:00'::TIMESTAMPTZ, '2020-10-26 00:00'::TIMESTAMPTZ, '1 hour');

These two statements should return the same results (might need to adjust the end time so they return the same number of rows).

@oeph
Copy link
Contributor Author

oeph commented May 7, 2021

sure, will do!

@oeph
Copy link
Contributor Author

oeph commented May 7, 2021

@oeph oeph force-pushed the generate_series-for-timestamps branch from fcb7d81 to 42144c5 Compare May 7, 2021 20:22
@blathers-crl
Copy link

blathers-crl bot commented May 7, 2021

Thank you for updating your pull request.

My owl senses detect your PR is good for review. Please keep an eye out for any test failures in CI.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan.

@oeph
Copy link
Contributor Author

oeph commented May 7, 2021

I added the test case that you suggested

Copy link
Member

@RaduBerinde RaduBerinde left a comment

Choose a reason for hiding this comment

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

Ah, sorry, I guess it is already implemented.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @oeph, @otan, and @yuzefovich)


pkg/sql/logictest/testdata/logic_test/builtin_function, line 3021 at r1 (raw file):

SET TIME ZONE +0

statement ok

This only tests that we don't crash.. We should use query to see the output so we can confirm that the two are equivalent.

@oeph
Copy link
Contributor Author

oeph commented May 8, 2021

@RaduBerinde is there a way to automatically compare the outputs of both query to match? I can't find any for the sqllogictest - can you maybe give me a hint? Or should I just add these both queries as standalone queries?

@oeph oeph force-pushed the generate_series-for-timestamps branch from 42144c5 to d950d65 Compare May 8, 2021 09:40
@RaduBerinde
Copy link
Member

Ah, it's not necessary, we can just visually compare. We can leave a comment saying that the results should be the same if they ever were to change. We review any changes to these files.

This adds `generate_series(timestamptz, timestamptz, interval)`
to the generate_series functions

Release note (sql change): adds generate_series for timestamptz values
@oeph oeph force-pushed the generate_series-for-timestamps branch from d950d65 to 723ded9 Compare May 8, 2021 13:59
@oeph
Copy link
Contributor Author

oeph commented May 8, 2021

@RaduBerinde I added a comment for this

Copy link
Member

@RaduBerinde RaduBerinde left a comment

Choose a reason for hiding this comment

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

Thank you! :lgtm:

bors r+

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @oeph, @otan, and @yuzefovich)

@craig
Copy link
Contributor

craig bot commented May 9, 2021

Build succeeded:

@craig craig bot merged commit 704e841 into cockroachdb:master May 9, 2021
Copy link
Contributor

@otan otan left a comment

Choose a reason for hiding this comment

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

thanks @oeph !

@oeph oeph deleted the generate_series-for-timestamps branch May 10, 2021 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-community Originated from the community X-blathers-triaged blathers was able to find an owner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sql: implement generate_series for timestamps
4 participants