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: complete eval functionality for TimeTZ #42687

Merged
merged 1 commit into from
Dec 3, 2019

Conversation

otan
Copy link
Contributor

@otan otan commented Nov 22, 2019

Refs: #26097

We want to support all operations that are supported by TimeTZ in
postgres:

  • equality, less than
  • timetz + date, interval + timetz
  • timetz + interval, interval + timetz
  • timetz - interval
otan=# select oprname, oprcode from pg_operator
where oprleft = 'timetz'::regtype or oprright = 'timetz'::regtype
     or oprresult = 'timetz'::regtype;
 oprname |      oprcode
---------+--------------------
 =       | timetz_eq
 <>      | timetz_ne
 <       | timetz_lt
 <=      | timetz_le
 >       | timetz_gt
 >=      | timetz_ge
 +       | datetimetz_pl
 +       | timetzdate_pl
 +       | timetz_pl_interval
 -       | timetz_mi_interval
 +       | interval_pl_timetz
(11 rows)

Release note: None

@otan otan requested review from solongordon and a team November 22, 2019 01:17
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@otan otan force-pushed the otan-timetz_operations branch 2 times, most recently from 1fcd27c to 5a70310 Compare November 22, 2019 19:29
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.

Reviewed 14 of 14 files at r1.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @otan)


pkg/sql/sem/tree/eval.go, line 611 at r1 (raw file):

					return nil, err
				}
				t := leftTime.Add(right.(*DTimeTZ).ToTime().Sub(timeutil.Unix(0, 0)))

Minor: The .Sub(timeutil.Unix(0, 0)) bit is a little mysterious. It might be nicer to add a ToDuration method on TimeOfDay or something.

@otan otan force-pushed the otan-timetz_operations branch 2 times, most recently from c79e5f5 to f2ffb41 Compare December 3, 2019 18:28
We want to support all operations that are supported by TimeTZ in
postgres:
* equality, less than
* timetz + date, interval + timetz
* timetz + interval, interval + timetz
* timetz - interval

```
otan=# select oprname, oprcode from pg_operator
where oprleft = 'timetz'::regtype or oprright = 'timetz'::regtype
     or oprresult = 'timetz'::regtype;
 oprname |      oprcode
---------+--------------------
 =       | timetz_eq
 <>      | timetz_ne
 <       | timetz_lt
 <=      | timetz_le
 >       | timetz_gt
 >=      | timetz_ge
 +       | datetimetz_pl
 +       | timetzdate_pl
 +       | timetz_pl_interval
 -       | timetz_mi_interval
 +       | interval_pl_timetz
(11 rows)
```

Release note: None
@otan
Copy link
Contributor Author

otan commented Dec 3, 2019

bors r+

@craig
Copy link
Contributor

craig bot commented Dec 3, 2019

Build failed

@otan
Copy link
Contributor Author

otan commented Dec 3, 2019

bors r+

craig bot pushed a commit that referenced this pull request Dec 3, 2019
42687: sql: complete eval functionality for TimeTZ r=otan a=otan

Refs: #26097

We want to support all operations that are supported by TimeTZ in
postgres:
* equality, less than
* timetz + date, interval + timetz
* timetz + interval, interval + timetz
* timetz - interval

```
otan=# select oprname, oprcode from pg_operator
where oprleft = 'timetz'::regtype or oprright = 'timetz'::regtype
     or oprresult = 'timetz'::regtype;
 oprname |      oprcode
---------+--------------------
 =       | timetz_eq
 <>      | timetz_ne
 <       | timetz_lt
 <=      | timetz_le
 >       | timetz_gt
 >=      | timetz_ge
 +       | datetimetz_pl
 +       | timetzdate_pl
 +       | timetz_pl_interval
 -       | timetz_mi_interval
 +       | interval_pl_timetz
(11 rows)
```

Release note: None

Co-authored-by: Oliver Tan <otan@cockroachlabs.com>
@craig
Copy link
Contributor

craig bot commented Dec 3, 2019

Build succeeded

@craig craig bot merged commit d062297 into cockroachdb:master Dec 3, 2019
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