From cd65999d27b53caaadb2b6aae61e923689ed595f Mon Sep 17 00:00:00 2001 From: edgar2020 Date: Mon, 29 Jul 2024 12:54:35 -0700 Subject: [PATCH 1/3] batch 5 --- docs/querying/sql-functions.md | 120 ++++++++++++++++++++++++++++----- 1 file changed, 105 insertions(+), 15 deletions(-) diff --git a/docs/querying/sql-functions.md b/docs/querying/sql-functions.md index f5219f6a4b27..92c7621c2cf5 100644 --- a/docs/querying/sql-functions.md +++ b/docs/querying/sql-functions.md @@ -605,11 +605,34 @@ Returns the rank for a row within a window without gaps. For example, if two row ## DIV -`DIV(x, y)` +Returns the result of integer division of `x` by `y`. -**Function type:** [Scalar, numeric](sql-scalar.md#numeric-functions) +* **Syntax:** `DIV(x, y)` +* **Function type:** Scalar, numeric -Returns the result of integer division of `x` by `y`. +
Example + + The following calculates integer divisions of `78` by `10`. + + ```sql + SELECT DIV(78, 10) as "division" + ``` + + Returns the following: + + | `division` | + | -- | + | `7` | + +
+ +:::info + + The `DIV` function is not implemented in Druid versions 30.0.0 or earlier. Consider using [`SAFE_DIVIDE`](./sql-functions.md/#safe_divide) instead. + +::: + +[Learn more](sql-scalar.md#numeric-functions) ## DS_CDF @@ -866,28 +889,78 @@ Returns a union of HLL sketches. ## HUMAN_READABLE_BINARY_BYTE_FORMAT -`HUMAN_READABLE_BINARY_BYTE_FORMAT(value[, precision])` +Converts an integer byte size into human-readable [IEC](https://en.wikipedia.org/wiki/Binary_prefix) format. -**Function type:** [Scalar, numeric](sql-scalar.md#numeric-functions) +* **Syntax:** `HUMAN_READABLE_BINARY_BYTE_FORMAT(value[, precision])` +* **Function type:** Scalar, numeric + +
Example + + Converts `1000000` into IEC format. -Converts an integer byte size into human-readable IEC format. + ```sql + SELECT HUMAN_READABLE_BINARY_BYTE_FORMAT(1000000, 2) AS "iec_format" + ``` + + Returns the following: + + | `iec_format` | + | -- | + | `976.56 KiB` | + +
+ +[Learn more](sql-scalar.md#numeric-functions) ## HUMAN_READABLE_DECIMAL_BYTE_FORMAT -`HUMAN_READABLE_DECIMAL_BYTE_FORMAT(value[, precision])` +Converts a byte size into human-readable [SI](https://en.wikipedia.org/wiki/Binary_prefix) format. -**Function type:** [Scalar, numeric](sql-scalar.md#numeric-functions) +* **Syntax:** `HUMAN_READABLE_DECIMAL_BYTE_FORMAT(value[, precision])` +* **Function type:** Scalar, numeric -Converts a byte size into human-readable SI format. +
Example -## HUMAN_READABLE_DECIMAL_FORMAT +Converts `1000000` into SI format. -`HUMAN_READABLE_DECIMAL_FORMAT(value[, precision])` +```sql +SELECT HUMAN_READABLE_DECIMAL_BYTE_FORMAT(1000000, 2) AS "si_format" +``` -**Function type:** [Scalar, numeric](sql-scalar.md#numeric-functions) +Returns the following: + +|`si_format`| +|--| +|`1.00 MB`| + +
+ +[Learn more](sql-scalar.md#numeric-functions) + +## HUMAN_READABLE_DECIMAL_FORMAT Converts a byte size into human-readable SI format with single-character units. +* **Syntax:** `HUMAN_READABLE_DECIMAL_FORMAT(value[, precision])` +* **Function type:** Scalar, numeric + +
Example + + Converts `1000000` into single character SI format. + +```sql +SELECT HUMAN_READABLE_DECIMAL_FORMAT(1000000, 2) AS "single_character_si_format" +``` + +Returns the following: + +|`single_character_si_format`| +|--| +|`1.00 M`| +
+ +[Learn more](sql-scalar.md#numeric-functions) + ## ICONTAINS_STRING `ICONTAINS_STRING(, str)` @@ -1430,11 +1503,28 @@ Trims characters from the trailing end of an expression. ## SAFE_DIVIDE -`SAFE_DIVIDE(x, y)` +Returns `x` divided by `y`, guarded on division by 0. -**Function type:** [Scalar, numeric](sql-scalar.md#numeric-functions) +* **Syntax:** `SAFE_DIVIDE(x, y)` +* **Function type:** Scalar, numeric -Returns `x` divided by `y`, guarded on division by 0. +
Example + +The following calculates divisions of integer `78` by integer `10`. + +```sql + SELECT SAFE_DIVIDE(78, 10) AS "safe_division" +``` + +Returns the following: + +|`safe_division`| +|--| +| `7` | + +
+ +[Learn more](sql-scalar.md#numeric-functions) ## SIN From aa90ca9de585915c9bdbde71ef73dd3c5e63f015 Mon Sep 17 00:00:00 2001 From: Benedict Jin Date: Tue, 30 Jul 2024 11:28:08 +0800 Subject: [PATCH 2/3] Update docs/querying/sql-functions.md --- docs/querying/sql-functions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/querying/sql-functions.md b/docs/querying/sql-functions.md index 92c7621c2cf5..3b5314127f92 100644 --- a/docs/querying/sql-functions.md +++ b/docs/querying/sql-functions.md @@ -1513,7 +1513,7 @@ Returns `x` divided by `y`, guarded on division by 0. The following calculates divisions of integer `78` by integer `10`. ```sql - SELECT SAFE_DIVIDE(78, 10) AS "safe_division" +SELECT SAFE_DIVIDE(78, 10) AS "safe_division" ``` Returns the following: From 1064ea3048e817d5edeca5b405da42734b05429d Mon Sep 17 00:00:00 2001 From: edgar2020 Date: Tue, 30 Jul 2024 12:55:12 -0700 Subject: [PATCH 3/3] applying suggestions --- docs/querying/sql-functions.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/querying/sql-functions.md b/docs/querying/sql-functions.md index 3b5314127f92..e43c03c44222 100644 --- a/docs/querying/sql-functions.md +++ b/docs/querying/sql-functions.md @@ -610,6 +610,7 @@ Returns the result of integer division of `x` by `y`. * **Syntax:** `DIV(x, y)` * **Function type:** Scalar, numeric + :::info @@ -896,7 +898,7 @@ Converts an integer byte size into human-readable [IEC](https://en.wikipedia.org
Example - Converts `1000000` into IEC format. + The following example converts `1000000` into IEC format. ```sql SELECT HUMAN_READABLE_BINARY_BYTE_FORMAT(1000000, 2) AS "iec_format" @@ -921,7 +923,7 @@ Converts a byte size into human-readable [SI](https://en.wikipedia.org/wiki/Bina
Example -Converts `1000000` into SI format. +The following example converts `1000000` into SI format. ```sql SELECT HUMAN_READABLE_DECIMAL_BYTE_FORMAT(1000000, 2) AS "si_format" @@ -946,7 +948,7 @@ Converts a byte size into human-readable SI format with single-character units.
Example - Converts `1000000` into single character SI format. + The following example converts `1000000` into single character SI format. ```sql SELECT HUMAN_READABLE_DECIMAL_FORMAT(1000000, 2) AS "single_character_si_format" @@ -1510,7 +1512,7 @@ Returns `x` divided by `y`, guarded on division by 0.
Example -The following calculates divisions of integer `78` by integer `10`. +The following example calculates divisions of integer `78` by integer `10`. ```sql SELECT SAFE_DIVIDE(78, 10) AS "safe_division"