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

builtins: make extract work with TimeTZ #42618

Merged
merged 1 commit into from
Nov 21, 2019

Conversation

otan
Copy link
Contributor

@otan otan commented Nov 20, 2019

Refs: #26097

Add extract for TimeTZ, which has a slight extension to that of Time and
a gotcha in epoch.

No release note as this will be combined in a later PR.

Release note: none

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@otan otan requested review from solongordon and a team November 20, 2019 20:01
Copy link
Contributor

@solongordon solongordon left a comment

Choose a reason for hiding this comment

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

I messed around a bit with Postgres and it seems like you should not be forcing all values to be positive:

solon=# select extract('timezone_hour' from '00:00-01:02'::TIMETZ);
 date_part
-----------
        -1
(1 row)

solon=# select extract('timezone_minute' from '00:00-01:02'::TIMETZ);
 date_part
-----------
        -2
(1 row)

solon=# select extract('timezone' from '00:00-01:02'::TIMETZ);
 date_part
-----------
     -3720
(1 row)

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @solongordon)

@otan
Copy link
Contributor Author

otan commented Nov 20, 2019

I messed around a bit with Postgres and it seems like you should not be forcing all values to be positive:

WEIRD i swear it didn't work... maybe i typed something else by accident..

@otan
Copy link
Contributor Author

otan commented Nov 20, 2019

oh.... i tested timestamptz....


otan=# select extract('timezone' from '2001-01-01 11:00+06:00'::timestamptz);
 date_part
-----------
     21600
(1 row)

otan=# select extract('timezone' from '2001-01-01 11:00-06:00'::timestamptz);
 date_part
-----------
     21600
(1 row)

otan=# select extract('timezone' from '2001-01-01 11:00+06:00'::timestamptz);
 date_part
-----------
     21600
(1 row)

@otan
Copy link
Contributor Author

otan commented Nov 20, 2019

oh it's even more subtle than that, for timestamp tz it's always where you are when you extract

@otan otan requested a review from solongordon November 20, 2019 22:59
Copy link
Contributor

@solongordon solongordon left a comment

Choose a reason for hiding this comment

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

:lgtm: modulo one documentation nit.

Reviewed 1 of 4 files at r1.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @otan and @solongordon)


pkg/sql/sem/builtins/builtins.go, line 1835 at r1 (raw file):

			},
			Info: "Extracts `element` from `input`.\n\n" +
				"Compatible elements: hour, minute, second, millisecond, microsecond, epoch\n" +

Minor: Missing , after epoch.

Add extract for TimeTZ, which has a slight extension to that of Time and
a gotcha in epoch.

No release note as this will be combined in a later PR.

Release note: none
@otan
Copy link
Contributor Author

otan commented Nov 20, 2019

bors r+

@craig
Copy link
Contributor

craig bot commented Nov 20, 2019

Build failed (retrying...)

craig bot pushed a commit that referenced this pull request Nov 20, 2019
42618: builtins: make extract work with TimeTZ r=otan a=otan

Refs: #26097

Add extract for TimeTZ, which has a slight extension to that of Time and
a gotcha in epoch.

No release note as this will be combined in a later PR.

Release note: none

Co-authored-by: Oliver Tan <[email protected]>
@craig
Copy link
Contributor

craig bot commented Nov 21, 2019

Build succeeded

@craig craig bot merged commit 13ba75b into cockroachdb:master Nov 21, 2019
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