cockroach icon indicating copy to clipboard operation
cockroach copied to clipboard

builtins: add trunc(decimal, int) builtin

Open rafiss opened this issue 3 years ago • 1 comments

fixes https://github.com/cockroachdb/cockroach/issues/85620

Release note (sql change): Added the trunc(decimal, int) builtin function, which truncates the given decimal value to the specified number of decimal places. A negative value can be used for the scale parameter, which will truncate to the left of the decimal point.

Example:

> select trunc(541.234, 2), trunc(541.234, 0), trunc(541.234, -1);

  trunc  | trunc | trunc
---------+-------+---------
  541.23 |   541 | 5.4E+2

rafiss avatar Aug 10 '22 14:08 rafiss

This change is Reviewable

cockroach-teamcity avatar Aug 10 '22 14:08 cockroach-teamcity

The latest CI is still failing with

client_merge_test.go:4753: ranges unexpectedly unmerged expected startKey /Table/106/1/1, but got /Table/106/1/2

Could this be related to the oid changes?

ZhouXing19 avatar Aug 12 '22 16:08 ZhouXing19

Where did you see those failures? I just see a data race for TestAdminAuditLogBasic which is caused by https://github.com/cockroachdb/cockroach/issues/85988 & https://github.com/cockroachdb/cockroach/issues/83080

rafiss avatar Aug 12 '22 16:08 rafiss

I saw it from here, in TestMergeQueueWithSlowNonVoterSnaps. But I just test this commit locally and it passed, so I'm guessing it was just a flake...

Other than the CI failures everything LGTM!

ZhouXing19 avatar Aug 12 '22 17:08 ZhouXing19

tftr!

bors r=ZhouXing19

rafiss avatar Aug 12 '22 17:08 rafiss

Build failed:

craig[bot] avatar Aug 12 '22 18:08 craig[bot]

bors r=ZhouXing19

rafiss avatar Aug 12 '22 22:08 rafiss

Build failed (retrying...):

craig[bot] avatar Aug 12 '22 22:08 craig[bot]

Build failed (retrying...):

craig[bot] avatar Aug 13 '22 01:08 craig[bot]

Build succeeded:

craig[bot] avatar Aug 13 '22 05:08 craig[bot]