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

[docs] batch 5 updating functions #16812

Merged
merged 3 commits into from
Jul 31, 2024
Merged
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
122 changes: 107 additions & 15 deletions docs/querying/sql-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -605,11 +605,36 @@ 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`.
<!--
<details><summary>Example</summary>

The following calculates integer divisions of `78` by `10`.

```sql
SELECT DIV(78, 10) as "division"
```

Returns the following:

| `division` |
| -- |
| `7` |

</details>
edgar2020 marked this conversation as resolved.
Show resolved Hide resolved
-->

:::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

Expand Down Expand Up @@ -866,28 +891,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

<details><summary>Example</summary>

The following example converts `1000000` into IEC format.

```sql
SELECT HUMAN_READABLE_BINARY_BYTE_FORMAT(1000000, 2) AS "iec_format"
```

Returns the following:

| `iec_format` |
| -- |
| `976.56 KiB` |

</details>

Converts an integer byte size into human-readable IEC format.
[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.
<details><summary>Example</summary>

## HUMAN_READABLE_DECIMAL_FORMAT
The following example 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`|

</details>

[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

<details><summary>Example</summary>

The following 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`|
</details>

[Learn more](sql-scalar.md#numeric-functions)

## ICONTAINS_STRING

`ICONTAINS_STRING(<expr>, str)`
Expand Down Expand Up @@ -1430,11 +1505,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.
<details><summary>Example</summary>

The following example calculates divisions of integer `78` by integer `10`.

```sql
SELECT SAFE_DIVIDE(78, 10) AS "safe_division"
```

Returns the following:

|`safe_division`|
|--|
| `7` |

</details>

[Learn more](sql-scalar.md#numeric-functions)

## SIN

Expand Down
Loading