You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by ht...@apache.org on 2019/07/02 14:55:12 UTC

[asterixdb] branch master updated: [NO ISSUE] Document ROUND function

This is an automated email from the ASF dual-hosted git repository.

htowaileb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/asterixdb.git


The following commit(s) were added to refs/heads/master by this push:
     new f89de3d  [NO ISSUE] Document ROUND function
f89de3d is described below

commit f89de3d72a23690693a7fae77997d12e54df1b3e
Author: Simon Dew <Si...@couchbase.com>
AuthorDate: Tue Jul 2 12:57:02 2019 +0100

    [NO ISSUE] Document ROUND function
    
        Add round() 2-args version documentation
    
        Edits after review of patch 1
    
    Change-Id: Id9087e61a11f643cb8b5ee881c35901a737bd4a4
    Reviewed-on: https://asterix-gerrit.ics.uci.edu/3472
    Sonar-Qube: Jenkins <je...@fulliautomatix.ics.uci.edu>
    Contrib: Jenkins <je...@fulliautomatix.ics.uci.edu>
    Tested-by: Jenkins <je...@fulliautomatix.ics.uci.edu>
    Integration-Tests: Jenkins <je...@fulliautomatix.ics.uci.edu>
    Reviewed-by: Hussain Towaileb <hu...@gmail.com>
---
 .../src/main/markdown/builtins/1_numeric_common.md | 35 ++++++++++++++++------
 1 file changed, 26 insertions(+), 9 deletions(-)

diff --git a/asterixdb/asterix-doc/src/main/markdown/builtins/1_numeric_common.md b/asterixdb/asterix-doc/src/main/markdown/builtins/1_numeric_common.md
index 611d82d..5afec07 100644
--- a/asterixdb/asterix-doc/src/main/markdown/builtins/1_numeric_common.md
+++ b/asterixdb/asterix-doc/src/main/markdown/builtins/1_numeric_common.md
@@ -435,16 +435,30 @@
 ### round ###
  * Syntax:
 
-        round(numeric_value)
+        round(numeric_value[, round_digit])
+
+ * Rounds the value to the given number of integer digits to the right of the decimal point,
+   or to the left of the decimal point if the number of digits is negative.
 
- * Computes the number with no fractional part that is closest (and also closest to positive infinity) to the argument.
  * Arguments:
-    * `numeric_value`: a `tinyint`/`smallint`/`integer`/`bigint`/`float`/`double` value.
+    * `numeric_value`: a `tinyint`/`smallint`/`integer`/`bigint`/`float`/`double` value
+      that represents the numeric value to be rounded.
+    * `round_digit`: (Optional) a `tinyint`/`smallint`/`integer`/`bigint`/`float`/`double` value
+      that specifies the digit to round to.
+      This argument may be positive or negative;
+      positive indicating that rounding needs to be to the right of the decimal point,
+      and negative indicating that rounding needs to be to the left of the decimal point.
+      Values such as 1.0 and 2.0 are acceptable, but values such as 1.3 and 1.5 result in a `null`.
+      If omitted, the default is 0.
  * Return Value:
-    * The rounded value for the given number in the same type as the input argument,
-    * `missing` if the argument is a `missing` value,
-    * `null` if the argument is a `null` value,
-    * any other non-numeric input value will cause a type error.
+    * The rounded value for the given number.
+      The returned value has the following type:
+        - `bigint` if the input value has type `tinyint`, `smallint`, `integer` or `bigint`,
+        - `float` if the input value has type `float`,
+        - `double` if the input value has type `double`;
+    * `missing` if the input value is a `missing` value,
+    * `null` if the input value is a `null` value,
+    * any other non-numeric input value will return a `null` value.
 
  * Example:
 
@@ -454,12 +468,15 @@
           "v3": round(0.8),
           "v4": round(float("-2013.256")),
           "v5": round(double("-2013.893823748327284"))
+          "v6": round(123456, -1),
+          "v7": round(456.456, 2),
+          "v8": round(456.456, -1),
+          "v9": round(-456.456, -2)
         };
 
-
  * The expected result is:
 
-        { "v1": 2013, "v2": -4036, "v3": 1.0, "v4": -2013.0, "v5": -2014.0 }
+        { "v1": 2013, "v2": -4036, "v3": 1.0, "v4": -2013.0, "v5": -2014.0, "v6": 123460, "v7": 456.46, "v8": 460, "v9": -500 }
 
 
 ### sign ###