Skip to content

sql: casting to timestamp should strip tz info#28128

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
jordanlewis:fix-cast-to-timestamp
Aug 1, 2018
Merged

sql: casting to timestamp should strip tz info#28128
craig[bot] merged 1 commit intocockroachdb:masterfrom
jordanlewis:fix-cast-to-timestamp

Conversation

@jordanlewis
Copy link
Copy Markdown
Member

And binary operations between timestamp and timestamptz should strip the
tz from the timestamptz.

Confirmed that all of this behavior matches postgres (and that it didn't
before).

Release note (bug fix): correct casts and binary operators between
timestamptz and timestamp in some cases.

@jordanlewis jordanlewis requested review from a team, dt, knz and solongordon August 1, 2018 06:03
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

fn: func(ctx *EvalContext, left Datum, right Datum) (Datum, error) {
// These two quantities aren't directly comparable. Convert the
// TimestampTZ to a timestamp first.
nanos := left.(*DTimestamp).Sub(right.(*DTimestampTZ).stripTimeZone(ctx).Time).Nanoseconds()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

please add tests in eval_test.go for these comparison function changes.

@jordanlewis jordanlewis force-pushed the fix-cast-to-timestamp branch from f5ce367 to 9464669 Compare August 1, 2018 06:33
@jordanlewis jordanlewis requested review from a team August 1, 2018 06:33
@jordanlewis
Copy link
Copy Markdown
Member Author

Done, PTAL

Copy link
Copy Markdown
Contributor

@knz knz left a comment

Choose a reason for hiding this comment

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

:lgtm: but please remove the debug printf

Reviewed 3 of 4 files at r1, 2 of 2 files at r2.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale)


pkg/sql/sem/tree/datum.go, line 2091 at r2 (raw file):

	_, locOffset := d.Time.In(ctx.GetLocation()).Zone()
	newTime := duration.Add(d.Time.UTC(), duration.FromInt64(int64(locOffset)))
	fmt.Println("Stripping", d, locOffset, newTime)

please remove the fmt.Println here

@jordanlewis
Copy link
Copy Markdown
Member Author

Oops, thanks for catching

And binary operations between timestamp and timestamptz should strip the
tz from the timestamptz.

Confirmed that all of this behavior matches postgres (and that it didn't
before).

Release note (bug fix): correct casts and binary operators between
timestamptz and timestamp in some cases.
@jordanlewis jordanlewis force-pushed the fix-cast-to-timestamp branch from 9464669 to 9583b06 Compare August 1, 2018 15:59
@jordanlewis
Copy link
Copy Markdown
Member Author

bors r+

craig bot pushed a commit that referenced this pull request Aug 1, 2018
28128: sql: casting to timestamp should strip tz info r=jordanlewis a=jordanlewis

And binary operations between timestamp and timestamptz should strip the
tz from the timestamptz.

Confirmed that all of this behavior matches postgres (and that it didn't
before).

Release note (bug fix): correct casts and binary operators between
timestamptz and timestamp in some cases.

28149: sql: avoid using Tuple in RangePartition r=knz a=knz

Forked off  #28143, needed for #25522 / #26624.

The `Tuple` AST node is really for scalar tuples. RangePartition is
not using a scalar tuple. So split them.

Release note: None

Co-authored-by: Jordan Lewis <jordanthelewis@gmail.com>
Co-authored-by: Raphael 'kena' Poss <knz@cockroachlabs.com>
@craig
Copy link
Copy Markdown
Contributor

craig bot commented Aug 1, 2018

Build succeeded

@craig craig bot merged commit 9583b06 into cockroachdb:master Aug 1, 2018
@jordanlewis jordanlewis deleted the fix-cast-to-timestamp branch August 1, 2018 16:20
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