Skip to content

sql: add precision support for TIME/TIMETZ#42668

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
otan-cockroach:otan-precision_time
Dec 3, 2019
Merged

sql: add precision support for TIME/TIMETZ#42668
craig[bot] merged 1 commit intocockroachdb:masterfrom
otan-cockroach:otan-precision_time

Conversation

@otan
Copy link
Copy Markdown
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
Copy Markdown
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 a team and solongordon November 21, 2019 21:57
@otan otan force-pushed the otan-precision_time branch from 1244ba5 to f769516 Compare November 21, 2019 22:43
Copy link
Copy Markdown
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.

@otan otan force-pushed the otan-precision_time branch from f769516 to 9100c31 Compare December 2, 2019 21:43
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 otan force-pushed the otan-precision_time branch from 9100c31 to 2c3ade7 Compare December 2, 2019 22:32
@otan
Copy link
Copy Markdown
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
Copy Markdown
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