mirror of https://github.com/apache/druid.git
[docs] batch02 of updating functions (#16761)
* applying changes * ensuring batch is updated * Update docs/querying/sql-functions.md * raise -> raises * addressing review * Apply suggestions from code review Co-authored-by: Charles Smith <techdocsmith@gmail.com> --------- Co-authored-by: Benedict Jin <asdf2014@apache.org> Co-authored-by: Charles Smith <techdocsmith@gmail.com>
This commit is contained in:
parent
6ff0cbfa54
commit
ca787885c9
|
@ -1069,11 +1069,30 @@ Returns the following:
|
||||||
|
|
||||||
## LOG10
|
## LOG10
|
||||||
|
|
||||||
`LOG10(expr)`
|
Calculates the base-10 logarithm of the numeric expression.
|
||||||
|
|
||||||
**Function type:** [Scalar, numeric](sql-scalar.md#numeric-functions)
|
* **Syntax:** `LOG10(<NUMERIC>)`
|
||||||
|
* **Function type:** Scalar, numeric
|
||||||
|
|
||||||
Calculates the base-10 of the numeric expression.
|
<details><summary>Example</summary>
|
||||||
|
|
||||||
|
The following example applies the LOG10 function to the `max_temperature` column from the `taxi-trips` datasource.
|
||||||
|
|
||||||
|
```sql
|
||||||
|
SELECT
|
||||||
|
"max_temperature" AS "max_temperature",
|
||||||
|
LOG10("max_temperature") AS "log10_max_temp"
|
||||||
|
FROM "taxi-trips"
|
||||||
|
LIMIT 1
|
||||||
|
```
|
||||||
|
Returns the following:
|
||||||
|
|
||||||
|
| `max_temperature` | `log10_max_temp` |
|
||||||
|
| -- | -- |
|
||||||
|
| `76` | `1.8808135922807914` |
|
||||||
|
</details>
|
||||||
|
|
||||||
|
[Learn more](sql-scalar.md#numeric-functions)
|
||||||
|
|
||||||
## LOOKUP
|
## LOOKUP
|
||||||
|
|
||||||
|
@ -1133,11 +1152,26 @@ Returns the minimum value of a set of values.
|
||||||
|
|
||||||
## MOD
|
## MOD
|
||||||
|
|
||||||
`MOD(x, y)`
|
Calculates x modulo y, or the remainder of x divided by y. Where x and y are numeric expressions.
|
||||||
|
|
||||||
**Function type:** [Scalar, numeric](sql-scalar.md#numeric-functions)
|
* **Syntax:** `MOD(x, y)`
|
||||||
|
* **Function type:** Scalar, numeric
|
||||||
|
|
||||||
Calculates x modulo y, or the remainder of x divided by y.
|
<details><summary>Example</summary>
|
||||||
|
|
||||||
|
The following calculates 78 MOD 10.
|
||||||
|
|
||||||
|
```sql
|
||||||
|
SELECT MOD(78, 10) as "modulo"
|
||||||
|
```
|
||||||
|
Returns the following:
|
||||||
|
|
||||||
|
| `modulo` |
|
||||||
|
| -- |
|
||||||
|
| `8` |
|
||||||
|
</details>
|
||||||
|
|
||||||
|
[Learn more](sql-scalar.md#numeric-functions)
|
||||||
|
|
||||||
## MV_APPEND
|
## MV_APPEND
|
||||||
|
|
||||||
|
@ -1317,12 +1351,27 @@ Returns the one-based index position of a substring within an expression, option
|
||||||
|
|
||||||
## POWER
|
## POWER
|
||||||
|
|
||||||
`POWER(expr, power)`
|
|
||||||
|
|
||||||
**Function type:** [Scalar, numeric](sql-scalar.md#numeric-functions)
|
|
||||||
|
|
||||||
Calculates a numerical expression raised to the specified power.
|
Calculates a numerical expression raised to the specified power.
|
||||||
|
|
||||||
|
* **Syntax:** `POWER(base, exponent)`
|
||||||
|
* **Function type:** Scalar, numeric
|
||||||
|
|
||||||
|
<details><summary>Example</summary>
|
||||||
|
|
||||||
|
The following example raises 5 to the power of 2.
|
||||||
|
|
||||||
|
```sql
|
||||||
|
SELECT POWER(5, 2) AS "power"
|
||||||
|
```
|
||||||
|
Returns the following:
|
||||||
|
|
||||||
|
| `power` |
|
||||||
|
| -- |
|
||||||
|
| `25` |
|
||||||
|
</details>
|
||||||
|
|
||||||
|
[Learn more](sql-scalar.md#numeric-functions)
|
||||||
|
|
||||||
## RADIANS
|
## RADIANS
|
||||||
|
|
||||||
`RADIANS(expr)`
|
`RADIANS(expr)`
|
||||||
|
@ -1398,12 +1447,32 @@ Returns the rightmost number of characters from an expression.
|
||||||
|
|
||||||
## ROUND
|
## ROUND
|
||||||
|
|
||||||
`ROUND(expr[, digits])`
|
|
||||||
|
|
||||||
**Function type:** [Scalar, numeric](sql-scalar.md#numeric-functions)
|
|
||||||
|
|
||||||
Calculates the rounded value for a numerical expression.
|
Calculates the rounded value for a numerical expression.
|
||||||
|
|
||||||
|
* **Syntax:** `ROUND(expr[, digits])`
|
||||||
|
* **Function type:** Scalar, numeric
|
||||||
|
|
||||||
|
<details><summary>Example</summary>
|
||||||
|
|
||||||
|
The following applies the ROUND function to 0 decimal points on the `pickup_longitude` column from the `taxi-trips` datasource.
|
||||||
|
|
||||||
|
```sql
|
||||||
|
SELECT
|
||||||
|
"pickup_longitude" AS "pickup_longitude",
|
||||||
|
ROUND("pickup_longitude", 0) as "rounded_pickup_longitude"
|
||||||
|
FROM "taxi-trips"
|
||||||
|
WHERE "pickup_longitude" IS NOT NULL
|
||||||
|
LIMIT 1
|
||||||
|
```
|
||||||
|
Returns the following:
|
||||||
|
|
||||||
|
| `pickup_longitude` | `rounded_pickup_longitude` |
|
||||||
|
| -- | -- |
|
||||||
|
| `-73.9377670288086` | `-74` |
|
||||||
|
</details>
|
||||||
|
|
||||||
|
[Learn more](sql-scalar.md#numeric-functions)
|
||||||
|
|
||||||
## ROW_NUMBER
|
## ROW_NUMBER
|
||||||
|
|
||||||
`ROW_NUMBER()`
|
`ROW_NUMBER()`
|
||||||
|
@ -1446,12 +1515,27 @@ Calculates the trigonometric sine of an angle expressed in radians.
|
||||||
|
|
||||||
## SQRT
|
## SQRT
|
||||||
|
|
||||||
`SQRT(expr)`
|
|
||||||
|
|
||||||
**Function type:** [Scalar, numeric](sql-scalar.md#numeric-functions)
|
|
||||||
|
|
||||||
Calculates the square root of a numeric expression.
|
Calculates the square root of a numeric expression.
|
||||||
|
|
||||||
|
* **Syntax:** `SQRT(<NUMERIC>)`
|
||||||
|
* **Function type:** Scalar, numeric
|
||||||
|
|
||||||
|
<details><summary>Example</summary>
|
||||||
|
|
||||||
|
The following example calculates the square root of 25.
|
||||||
|
|
||||||
|
```sql
|
||||||
|
SELECT SQRT(25) AS "square_root"
|
||||||
|
```
|
||||||
|
Returns the following:
|
||||||
|
|
||||||
|
| `square_root` |
|
||||||
|
| -- |
|
||||||
|
| `5` |
|
||||||
|
</details>
|
||||||
|
|
||||||
|
[Learn more](sql-scalar.md#numeric-functions)
|
||||||
|
|
||||||
## STDDEV
|
## STDDEV
|
||||||
|
|
||||||
`STDDEV(expr)`
|
`STDDEV(expr)`
|
||||||
|
@ -1720,20 +1804,41 @@ Trims the leading or trailing characters of an expression.
|
||||||
|
|
||||||
## TRUNC
|
## TRUNC
|
||||||
|
|
||||||
`TRUNC(expr[, digits])`
|
|
||||||
|
|
||||||
**Function type:** [Scalar, numeric](sql-scalar.md#numeric-functions)
|
|
||||||
|
|
||||||
Alias for [`TRUNCATE`](#truncate).
|
Alias for [`TRUNCATE`](#truncate).
|
||||||
|
|
||||||
|
* **Syntax:** `TRUNC(expr[, digits])`
|
||||||
|
* **Function type:** Scalar, numeric
|
||||||
|
|
||||||
|
[Learn more](sql-scalar.md#numeric-functions)
|
||||||
|
|
||||||
## TRUNCATE
|
## TRUNCATE
|
||||||
|
|
||||||
`TRUNCATE(expr[, digits])`
|
|
||||||
|
|
||||||
**Function type:** [Scalar, numeric](sql-scalar.md#numeric-functions)
|
|
||||||
|
|
||||||
Truncates a numerical expression to a specific number of decimal digits.
|
Truncates a numerical expression to a specific number of decimal digits.
|
||||||
|
|
||||||
|
* **Syntax:** `TRUNCATE(expr[, digits])`
|
||||||
|
* **Function type:** Scalar, numeric
|
||||||
|
|
||||||
|
<details><summary>Example</summary>
|
||||||
|
|
||||||
|
The following applies the TRUNCATE function to 1 decimal place on the `pickup_longitude` column from the `taxi-trips` datasource.
|
||||||
|
|
||||||
|
```sql
|
||||||
|
SELECT
|
||||||
|
"pickup_longitude" as "pickup_longitude",
|
||||||
|
TRUNCATE("pickup_longitude", 1) as "truncate_pickup_longitude"
|
||||||
|
FROM "taxi-trips"
|
||||||
|
WHERE "pickup_longitude" IS NOT NULL
|
||||||
|
LIMIT 1
|
||||||
|
```
|
||||||
|
Returns the following:
|
||||||
|
|
||||||
|
| `pickup_longitude` | `truncate_pickup_longitude` |
|
||||||
|
| -- | -- |
|
||||||
|
| `-73.9377670288086` | `-73.9` |
|
||||||
|
</details>
|
||||||
|
|
||||||
|
|
||||||
|
[Learn more](sql-scalar.md#numeric-functions)
|
||||||
|
|
||||||
## TRY_PARSE_JSON
|
## TRY_PARSE_JSON
|
||||||
|
|
||||||
|
@ -1783,3 +1888,4 @@ Calculates the sample variance of a set of values.
|
||||||
|
|
||||||
Alias for [`VAR_SAMP`](#var_samp).
|
Alias for [`VAR_SAMP`](#var_samp).
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue