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

sql: add precision support for TIME/TIMETZ #42668

Merged
merged 1 commit into from
Dec 3, 2019

Conversation

otan
Copy link
Contributor

@otan otan commented Nov 21, 2019

Refs: #32565
Refs: #26097

Adding support for precision for both TIME and TIMETZ. This also
includes threading through some extra parsing syntax for TIMETZ.

ALTER TABLE between TIME and TIMETZ not supported as they have different
representations.

Release note (sql change): This PR adds new support for precision for
TIME types (e.g. TIME(3) will truncate to milliseconds). Previously this
would raise syntax errors.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@otan otan changed the title sql: add precision for TIME/TIMETZ sql: add precision support for TIME/TIMETZ Nov 21, 2019
@otan otan force-pushed the otan-precision_time branch 3 times, most recently from 374d633 to 1244ba5 Compare November 21, 2019 21:56
@otan otan requested review from solongordon and a team November 21, 2019 21:57
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.

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


pkg/util/timeofday/time_of_day.go, line 106 at r1 (raw file):

	}
	ret := t.ToTime().Round(precision)
	// Rounding Max should give Time2400, not 00:00.

Good catch!


pkg/util/timeofday/time_of_day.go, line 108 at r1 (raw file):

	// Rounding Max should give Time2400, not 00:00.
	// To catch this, see if we went to the next day.
	if ret.Day() == 2 {

Nit: Could make this ret.Day() != t.ToTime().Day() to get rid of the magical constant and make it less sensitive to the underlying ToTime() behavior.

Adding support for precision for both TIME and TIMETZ. This also
includes threading through some extra parsing syntax for TIMETZ.

ALTER TABLE between TIME and TIMETZ not supported as they have different
representations.

Release note (sql change): This PR adds new support for precision for
TIME types (e.g. TIME(3) will truncate to milliseconds). Previously this
would raise syntax errors.
@otan
Copy link
Contributor Author

otan commented Dec 2, 2019

bors r+

craig bot pushed a commit that referenced this pull request Dec 3, 2019
42668: sql: add precision support for TIME/TIMETZ r=otan a=otan

Refs: #32565
Refs: #26097 

Adding support for precision for both TIME and TIMETZ. This also
includes threading through some extra parsing syntax for TIMETZ.

ALTER TABLE between TIME and TIMETZ not supported as they have different
representations.

Release note (sql change): This PR adds new support for precision for
TIME types (e.g. TIME(3) will truncate to milliseconds). Previously this
would raise syntax errors.

42864: rfcs: new RFC on fixing the halloween problem r=knz a=knz

I am splitting this RFC away from the [RFC on savepoints](#41569) because I know recognize it is a different problem with an orthogonal solution.

https://github.com/knz/cockroach/blob/20191129-rfc-halloween/docs/RFCS/20191014_halloween.md

There is no new idea in this text (I copy-pasted the text from the other RFC) and the implementation PRs are already out, so if the reviewers are satisfied I would gladly already merge the RFC as in-progress or completed.

Co-authored-by: Oliver Tan <otan@cockroachlabs.com>
Co-authored-by: Raphael 'kena' Poss <knz@thaumogen.net>
@craig
Copy link
Contributor

craig bot commented Dec 3, 2019

Build succeeded

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