-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
sql: Added TIMETZ column type and datum #24343
Conversation
It might be nice to split this into two commits.
Reviewed 12 of 48 files at r1. pkg/sql/logictest/testdata/logic_test/timetz, line 5 at r1 (raw file):
It would be nice if you used subtests when splitting the sections. Comments from Reviewable |
It might be nice to split this into two commits.
Overall the change looks good, but I'll leave most of the logic and test coverage reviewing to @dt. Reviewed 12 of 48 files at r1. Comments from Reviewable |
Can you also extend the |
Great stuff here! Also, wow, there is a lot involved in adding a new type these days I haven't quite done a line-by-line review yet, but from a quick look, there were two things I was wondering about: the encoding choice, and logic test coverage. For encoding, looking at the Second, there's chunk of the Reviewed 15 of 48 files at r1. Comments from Reviewable |
c892894
to
abb504c
Compare
If you get a chance, you should rebase on master, I added a handful of tests in #24537 which will require modifications to this PR, I think. |
@dt I've changed encoding to int, and expanded the test coverage. All logic tests are in |
Nice! One more nit on encoding part. Reviewed 1 of 48 files at r1. pkg/sql/sqlbase/table.go, line 567 at r2 (raw file):
I'm not clear on why this is different from the pkg/sql/sqlbase/table.go, line 656 at r2 (raw file):
ditto above. Comments from Reviewable |
Review status: 25 of 48 files reviewed at latest revision, 3 unresolved discussions, some commit checks failed. pkg/sql/sqlbase/table.go, line 567 at r2 (raw file): Previously, dt (David Taylor) wrote…
I don't think we can. It's mainly because DTimeTZ is not just a wrapper around int64. It also holds a pointer to time zone. So we have to translate DTimeTZ to I will add the comments shortly. pkg/sql/sqlbase/table.go, line 656 at r2 (raw file): Previously, dt (David Taylor) wrote…
Done. Comments from Reviewable |
Reviewed 10 of 48 files at r1, 1 of 7 files at r2. pkg/sql/sqlbase/table.go, line 567 at r2 (raw file): Previously, windchan7 (Victor Chen) wrote…
Huh, okay. So f it works as is -- i.e. all the test here match postgres behavior and pass -- then I'm fine with it. I'm just trying to figure out why it is different: In my head, since we don't actually store a zone in KV it seems like the in-memory representation could be just a timeofday as well, with the session offset logic being handled where we cast, print, or wire encode it. again though, if the current approach works, Comments from Reviewable |
This is an implementation of the PostgreSQL TIMETZ type, which represents time of day, with time zone. We store this as a struct wrapper around an int64 (TimeOfDay) and a *time.Location. Just like TIMESTAMPTZ, TIMETZ does not store any time zone information internally. The time zone is for user display only. In addition, the CURRENT_TIME built in is added. Note that this commit does not attempt to support any new time formats beyond what we already support in the time portion of TIMESTAMP. This means that many formats which Postgres accepts (04:05, 040506, 04:05 PM, allballs) are not yet handled. Closes cockroachdb#20944. Release note (SQL change): Added TIMETZ column type and datum.
bors r+ |
24343: sql: Added TIMETZ column type and datum r=windchan7 a=windchan7 This is an implementation of the PostgreSQL TIMETZ type, which represents time of day, with time zone. We store this as a struct wrapper around an int64 (TimeOfDay) and a *time.Location. Just like TIMESTAMPTZ, TIMETZ does not store any time zone information internally. The time zone is for user display only. In addition, the CURRENT_TIME built in is added. Note that this commit does not attempt to support any new time formats beyond what we already support in the time portion of TIMESTAMP. This means that many formats which Postgres accepts (04:05, 040506, 04:05 PM, allballs) are not yet handled. Closes #20944. Release note (SQL change): Added TIMETZ column type and datum. Co-authored-by: Victor Chen <[email protected]>
Build succeeded |
This is an implementation of the PostgreSQL TIMETZ type, which represents time
of day, with time zone. We store this as a struct wrapper around an int64
(TimeOfDay) and a *time.Location. Just like TIMESTAMPTZ, TIMETZ does not store
any time zone information internally. The time zone is for user display only.
In addition, the CURRENT_TIME built in is added.
Note that this commit does not attempt to support any new time formats beyond
what we already support in the time portion of TIMESTAMP. This means that many
formats which Postgres accepts (04:05, 040506, 04:05 PM, allballs) are not yet
handled.
Closes #20944.
Release note (SQL change): Added TIMETZ column type and datum.