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

release-21.2: coexec: normalize the timestamp subtraction like postgres #84002

Merged
merged 1 commit into from
Jul 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pkg/sql/colexec/colexecproj/proj_const_left_ops.eg.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions pkg/sql/colexec/colexecproj/proj_const_right_ops.eg.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions pkg/sql/colexec/colexecproj/proj_non_const_ops.eg.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/sql/colexec/execgen/cmd/execgen/overloads_bin.go
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ func (c timestampCustomizer) getBinOpAssignFunc() assignFunc {
case tree.Minus:
return fmt.Sprintf(`
nanos := %[2]s.Sub(%[3]s).Nanoseconds()
%[1]s = duration.MakeDuration(nanos, 0, 0)
%[1]s = duration.MakeDurationJustifyHours(nanos, 0, 0)
`,
targetElem, leftElem, rightElem)
default:
Expand Down
11 changes: 11 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/timestamp
Original file line number Diff line number Diff line change
Expand Up @@ -516,3 +516,14 @@ SELECT date_trunc('day', t), date_trunc('hour', t) FROM (VALUES
----
2020-10-25 00:00:00 +0300 EEST 2020-10-25 03:00:00 +0300 EEST
2020-10-25 00:00:00 +0300 EEST 2020-10-25 03:00:00 +0200 EET

# Regression test for #83094 (vectorized engine incorrectly formatting an
# interval).
statement ok
CREATE TABLE t (t1 timestamptz, t2 timestamptz);
INSERT INTO t VALUES ('2022-01-01 00:00:00.000000+00:00', '2022-01-02 00:00:00.000000+00:00');

query T
SELECT (t2 - t1) FROM t
----
1 day