

# Built-In Functions

Flink Table API & SQL provides users with a set of built-in functions for data transformations. This page gives a brief overview of them. If a function that you need is not supported yet, you can implement a [user-defined function](udfs.html). If you think that the function is general enough, please [open a Jira issue](https://issues.apache.org/jira/secure/CreateIssue!default.jspa) for it with a detailed description.

## Scalar Functions

The scalar functions take zero, one or more values as the input and return a single value as the result.

### Comparison Functions

| Comparison functions | Description |
| --- | --- |
| 



```
value1 = value2
```



Returns TRUE if _value1_ is equal to _value2_; returns UNKNOWN if _value1_ or _value2_ is NULL.



```
value1 &lt;&gt; value2
```



Returns TRUE if _value1_ is not equal to _value2_; returns UNKNOWN if _value1_ or _value2_ is NULL.



```
value1 &gt; value2
```



Returns TRUE if _value1_ is greater than _value2_; returns UNKNOWN if _value1_ or _value2_ is NULL.



```
value1 &gt;= value2
```



Returns TRUE if _value1_ is greater than or equal to _value2_; returns UNKNOWN if _value1_ or _value2_ is NULL.



```
value1 &lt; value2
```



Returns TRUE if _value1_ is less than _value2_; returns UNKNOWN if _value1_ or _value2_ is NULL.



```
value1 &lt;= value2
```



Returns TRUE if _value1_ is less than or equal to _value2_; returns UNKNOWN if _value1_ or _value2_ is NULL.



```
value IS NULL
```



Returns TRUE if _value_ is NULL.



```
value IS NOT NULL
```



Returns TRUE if _value_ is not NULL.



```
value1 IS DISTINCT FROM value2
```



Returns TRUE if two values are not equal. NULL values are treated as identical here.E.g., `1 IS DISTINCT FROM NULL` returns TRUE; `NULL IS DISTINCT FROM NULL` returns FALSE.



```
value1 IS NOT DISTINCT FROM value2
```



Returns TRUE if two values are equal. NULL values are treated as identical here.E.g., `1 IS NOT DISTINCT FROM NULL` returns FALSE; `NULL IS NOT DISTINCT FROM NULL` returns TRUE.



```
value1 BETWEEN [ ASYMMETRIC &#124; SYMMETRIC ] value2 AND value3
```



By default (or with the ASYMMETRIC keyword), returns TRUE if _value1_ is greater than or equal to _value2_ and less than or equal to _value3_. With the SYMMETRIC keyword, returns TRUE if _value1_ is inclusively between _value2_ and _value3_. When either _value2_ or _value3_ is NULL, returns FALSE or UNKNOWN.E.g., `12 BETWEEN 15 AND 12` returns FALSE; `12 BETWEEN SYMMETRIC 15 AND 12` returns TRUE; `12 BETWEEN 10 AND NULL` returns UNKNOWN; `12 BETWEEN NULL AND 10` returns FALSE; `12 BETWEEN SYMMETRIC NULL AND 12` returns UNKNOWN.



```
value1 NOT BETWEEN [ ASYMMETRIC &#124; SYMMETRIC ] value2 AND value3
```



By default (or with the ASYMMETRIC keyword), returns TRUE if _value1_ is less than _value2_ or greater than _value3_. With the SYMMETRIC keyword, returns TRUE if _value1_ is not inclusively between _value2_ and _value3_. When either _value2_ or _value3_ is NULL, returns TRUE or UNKNOWN.E.g., `12 NOT BETWEEN 15 AND 12` returns TRUE; `12 NOT BETWEEN SYMMETRIC 15 AND 12` returns FALSE; `12 NOT BETWEEN NULL AND 15` returns UNKNOWN; `12 NOT BETWEEN 15 AND NULL` returns TRUE; `12 NOT BETWEEN SYMMETRIC 12 AND NULL` returns UNKNOWN.



```
string1 LIKE string2 [ ESCAPE char ]
```



Returns TRUE if _string1_ matches pattern _string2_; returns UNKNOWN if _string1_ or _string2_ is NULL. An escape character can be defined if necessary.**Note:** The escape character has not been supported yet.



```
string1 NOT LIKE string2 [ ESCAPE char ]
```



Returns TRUE if _string1_ does not match pattern _string2_; returns UNKNOWN if _string1_ or _string2_ is NULL. An escape character can be defined if necessary.**Note:** The escape character has not been supported yet.



```
string1 SIMILAR TO string2 [ ESCAPE char ]
```



Returns TRUE if _string1_ matches SQL regular expression _string2_; returns UNKNOWN if _string1_ or _string2_ is NULL. An escape character can be defined if necessary.**Note:** The escape character has not been supported yet.



```
string1 NOT SIMILAR TO string2 [ ESCAPE char ]
```



Returns TRUE if _string1_ does not match SQL regular expression _string2_; returns UNKNOWN if _string1_ or _string2_ is NULL. An escape character can be defined if necessary.**Note:** The escape character has not been supported yet.



```
value1 IN (value2 [, value3]* )
```



Returns TRUE if _value1_ exists in the given list _(value2, value3, ...)_. When _(value2, value3, ...)_. contains NULL, returns TRUE if the element can be found and UNKNOWN otherwise. Always returns UNKNOWN if _value1_ is NULL.E.g., `4 IN (1, 2, 3)` returns FALSE; `1 IN (1, 2, NULL)` returns TRUE; `4 IN (1, 2, NULL)` returns UNKNOWN.



```
value1 NOT IN (value2 [, value3]* )
```



Returns TRUE if _value1_ does not exist in the given list _(value2, value3, ...)_. When _(value2, value3, ...)_. contains NULL, returns FALSE if _value1_ can be found and UNKNOWN otherwise. Always returns UNKNOWN if _value1_ is NULL.E.g., `4 NOT IN (1, 2, 3)` returns TRUE; `1 NOT IN (1, 2, NULL)` returns FALSE; `4 NOT IN (1, 2, NULL)` returns UNKNOWN.



```
EXISTS (sub-query)
```



Returns TRUE if _sub-query_ returns at least one row. Only supported if the operation can be rewritten in a join and group operation.**Note:** For streaming queries the operation is rewritten in a join and group operation. The required state to compute the query result might grow infinitely depending on the number of distinct input rows. Please provide a query configuration with valid retention interval to prevent excessive state size. See [Query Configuration](streaming/query_configuration.html) for details.



```
value IN (sub-query)
```



Returns TRUE if _value_ is equal to a row returned by sub-query.**Note:** For streaming queries the operation is rewritten in a join and group operation. The required state to compute the query result might grow infinitely depending on the number of distinct input rows. Please provide a query configuration with valid retention interval to prevent excessive state size. See [Query Configuration](streaming/query_configuration.html) for details.



```
value NOT IN (sub-query)
```



 | Returns TRUE if _value_ is not equal to every row returned by _sub-query_.**Note:** For streaming queries the operation is rewritten in a join and group operation. The required state to compute the query result might grow infinitely depending on the number of distinct input rows. Please provide a query configuration with valid retention interval to prevent excessive state size. See [Query Configuration](streaming/query_configuration.html) for details. |

| Comparison functions | Description |
| --- | --- |
| 



```
ANY1 === ANY2
```



Returns TRUE if _ANY1_ is equal to _ANY2_; returns UNKNOWN if _ANY1_ or _ANY2_ is NULL.



```
ANY1 !== ANY2
```



Returns TRUE if _ANY1_ is not equal to _ANY2_; returns UNKNOWN if _ANY1_ or _ANY2_ is NULL.



```
ANY1 &gt; ANY2
```



Returns TRUE if _ANY1_ is greater than _ANY2_; returns UNKNOWN if _ANY1_ or _ANY2_ is NULL.



```
ANY1 &gt;= ANY2
```



Returns TRUE if _ANY1_ is greater than or equal to _ANY2_; returns UNKNOWN if _ANY1_ or _ANY2_ is NULL.



```
ANY1 &lt; ANY2
```



Returns TRUE if _ANY1_ is less than _ANY2_; returns UNKNOWN if _ANY1_ or _ANY2_ is NULL.



```
ANY1 &lt;= ANY2
```



Returns TRUE if _ANY1_ is less than or equal to _ANY2_; returns UNKNOWN if _ANY1_ or _ANY2_ is NULL.



```
ANY.isNull
```



Returns TRUE if _ANY_ is NULL.



```
ANY.isNotNull
```



Returns TRUE if _ANY_ is not NULL.



```
STRING1.like(STRING2)
```



Returns TRUE if _STRING1_ matches pattern _STRING2_; returns UNKNOWN if _STRING1_ or _STRING2_ is NULL.E.g., `"JoKn".like("Jo_n%")` returns TRUE.



```
STRING.similar(STRING)
```



Returns TRUE if _STRING1_ matches SQL regular expression _STRING2_; returns UNKNOWN if _STRING1_ or _STRING2_ is NULL.E.g., `"A".similar("A+")` returns TRUE.



```
ANY1.in(ANY2, ANY3, ...)
```



Returns TRUE if _ANY1_ exists in a given list _(ANY2, ANY3, ...)_. When _(ANY2, ANY3, ...)_. contains NULL, returns TRUE if the element can be found and UNKNOWN otherwise. Always returns UNKNOWN if _ANY1_ is NULL.E.g., `4.in(1, 2, 3)` returns FALSE.



```
ANY.in(TABLE)
```



Returns TRUE if _ANY_ is equal to a row returned by sub-query _TABLE_.**Note:** For streaming queries the operation is rewritten in a join and group operation. The required state to compute the query result might grow infinitely depending on the number of distinct input rows. Please provide a query configuration with valid retention interval to prevent excessive state size. See [Query Configuration](streaming/query_configuration.html) for details.



```
ANY1.between(ANY2, ANY3)
```



Returns TRUE if _ANY1_ is greater than or equal to _ANY2_ and less than or equal to _ANY3_. When either _ANY2_ or _ANY3_ is NULL, returns FALSE or UNKNOWN.E.g., `12.between(15, 12)` returns FALSE; `12.between(10, Null(INT))` returns UNKNOWN; `12.between(Null(INT), 10)` returns FALSE.



```
ANY1.notBetween(ANY2, ANY3)
```



 | Returns TRUE if _ANY1_ is less than _ANY2_ or greater than _ANY3_. When either _ANY2_ or _ANY3_ is NULL, returns TRUE or UNKNOWN.E.g., `12.notBetween(15, 12)` returns TRUE; `12.notBetween(Null(INT), 15)` returns UNKNOWN; `12.notBetween(15, Null(INT))` returns TRUE. |

| Comparison functions | Description |
| --- | --- |
| 



```
ANY1 === ANY2
```



Returns TRUE if _ANY1_ is equal to _ANY2_; returns UNKNOWN if _ANY1_ or _ANY2_ is NULL.



```
ANY1 !== ANY2
```



Returns TRUE if _ANY1_ is not equal to _ANY2_; returns UNKNOWN if _ANY1_ or _ANY2_ is NULL.



```
ANY1 &gt; ANY2
```



Returns TRUE if _ANY1_ is greater than _ANY2_; returns UNKNOWN if _ANY1_ or _ANY2_ is NULL.



```
ANY1 &gt;= ANY2
```



Returns TRUE if _ANY1_ is greater than or equal to _ANY2_; returns UNKNOWN if _ANY1_ or _ANY2_ is NULL.



```
ANY1 &lt; ANY2
```



Returns TRUE if _ANY1_ is less than _ANY2_; returns UNKNOWN if _ANY1_ or _ANY2_ is NULL.



```
ANY1 &lt;= ANY2
```



Returns TRUE if _ANY1_ is less than or equal to _ANY2_; returns UNKNOWN if _ANY1_ or _ANY2_ is NULL.



```
ANY.isNull
```



Returns TRUE if _ANY_ is NULL.



```
ANY.isNotNull
```



Returns TRUE if _ANY_ is not NULL.



```
STRING1.like(STRING2)
```



Returns TRUE if _STRING1_ matches pattern _STRING2_; returns UNKNOWN if _STRING1_ or _STRING2_ is NULL.E.g., `"JoKn".like("Jo_n%")` returns TRUE.



```
STRING1.similar(STRING2)
```



Returns TRUE if _STRING1_ matches SQL regular expression _STRING2_; returns UNKNOWN if _STRING1_ or _STRING2_ is NULL.E.g., `"A".similar("A+")` returns TRUE.



```
ANY1.in(ANY2, ANY3, ...)
```



Returns TRUE if _ANY1_ exists in a given list _(ANY2, ANY3, ...)_. When _(ANY2, ANY3, ...)_. contains NULL, returns TRUE if the element can be found and UNKNOWN otherwise. Always returns UNKNOWN if _ANY1_ is NULL.E.g., `4.in(1, 2, 3)` returns FALSE.



```
ANY.in(TABLE)
```



Returns TRUE if _ANY_ is equal to a row returned by sub-query _TABLE_.**Note:** For streaming queries the operation is rewritten in a join and group operation. The required state to compute the query result might grow infinitely depending on the number of distinct input rows. Please provide a query configuration with valid retention interval to prevent excessive state size. See [Query Configuration](streaming/query_configuration.html) for details.



```
ANY1.between(ANY2, ANY3)
```



Returns TRUE if _ANY1_ is greater than or equal to _ANY2_ and less than or equal to _ANY3_. When either _ANY2_ or _ANY3_ is NULL, returns FALSE or UNKNOWN.E.g., `12.between(15, 12)` returns FALSE; `12.between(10, Null(Types.INT))` returns UNKNOWN; `12.between(Null(Types.INT), 10)` returns FALSE.



```
ANY1.notBetween(ANY2, ANY3)
```



 | Returns TRUE if _ANY1_ is less than _ANY2_ or greater than _ANY3_. When either _ANY2_ or _ANY3_ is NULL, returns TRUE or UNKNOWN.E.g., `12.notBetween(15, 12)` returns TRUE; `12.notBetween(Null(Types.INT), 15)` returns UNKNOWN; `12.notBetween(15, Null(Types.INT))` returns TRUE. |

### Logical Functions

| Logical functions | Description |
| --- | --- |
| 



```
boolean1 OR boolean2
```



Returns TRUE if _boolean1_ is TRUE or _boolean2_ is TRUE. Supports three-valued logic.E.g., `TRUE OR UNKNOWN` returns TRUE.



```
boolean1 AND boolean2
```



Returns TRUE if _boolean1_ and _boolean2_ are both TRUE. Supports three-valued logic.E.g., `TRUE AND UNKNOWN` returns UNKNOWN.



```
NOT boolean
```



Returns TRUE if _boolean_ is FALSE; returns FALSE if _boolean_ is TRUE; returns UNKNOWN if _boolean_ is UNKNOWN.



```
boolean IS FALSE
```



Returns TRUE if _boolean_ is FALSE; returns FALSE if _boolean_ is TRUE or UNKNOWN.



```
boolean IS NOT FALSE
```



Returns TRUE if _boolean_ is TRUE or UNKNOWN; returns FALSE if _boolean_ is FALSE.



```
boolean IS TRUE
```



Returns TRUE if _boolean_ is TRUE; returns FALSE if _boolean_ is FALSE or UNKNOWN.



```
boolean IS NOT TRUE
```



Returns TRUE if _boolean_ is FALSE or UNKNOWN; returns FALSE if _boolean_ is FALSE.



```
boolean IS UNKNOWN
```



Returns TRUE if _boolean_ is UNKNOWN; returns FALSE if _boolean_ is TRUE or FALSE.



```
boolean IS NOT UNKNOWN
```



 | Returns TRUE if _boolean_ is TRUE or FALSE; returns FALSE if _boolean_ is UNKNOWN. |

| Logical functions | Description |
| --- | --- |
| 



```
BOOLEAN1 &#124;&#124; BOOLEAN2
```



Returns TRUE if _BOOLEAN1_ is TRUE or _BOOLEAN2_ is TRUE. Supports three-valued logic.E.g., `true &#124;&#124; Null(BOOLEAN)` returns TRUE.



```
BOOLEAN1 && BOOLEAN2
```



Returns TRUE if _BOOLEAN1_ and _BOOLEAN2_ are both TRUE. Supports three-valued logic.E.g., `true && Null(BOOLEAN)` returns UNKNOWN.



```
!BOOLEAN
```



Returns TRUE if _BOOLEAN_ is FALSE; returns FALSE if _BOOLEAN_ is TRUE; returns UNKNOWN if _BOOLEAN_ is UNKNOWN.



```
BOOLEAN.isTrue
```



Returns TRUE if _BOOLEAN_ is TRUE; returns FALSE if _BOOLEAN_ is FALSE or UNKNOWN.



```
BOOLEAN.isFalse
```



Returns TRUE if _BOOLEAN_ is FALSE; returns FALSE if _BOOLEAN_ is TRUE or UNKNOWN.



```
BOOLEAN.isNotTrue
```



Returns TRUE if _BOOLEAN_ is FALSE or UNKNOWN; returns FALSE if _BOOLEAN_ is FALSE.



```
BOOLEAN.isNotFalse
```



 | Returns TRUE if _BOOLEAN_ is TRUE or UNKNOWN; returns FALSE if _BOOLEAN_ is FALSE. |

| Logical functions | Description |
| --- | --- |
| 



```
BOOLEAN1 &#124;&#124; BOOLEAN2
```



Returns TRUE if _BOOLEAN1_ is TRUE or _BOOLEAN2_ is TRUE. Supports three-valued logic.E.g., `true &#124;&#124; Null(Types.BOOLEAN)` returns TRUE.



```
BOOLEAN1 && BOOLEAN2
```



Returns TRUE if _BOOLEAN1_ and _BOOLEAN2_ are both TRUE. Supports three-valued logic.E.g., `true && Null(Types.BOOLEAN)` returns UNKNOWN.



```
!BOOLEAN
```



Returns TRUE if _BOOLEAN_ is FALSE; returns FALSE if _BOOLEAN_ is TRUE; returns UNKNOWN if _BOOLEAN_ is UNKNOWN.



```
BOOLEAN.isTrue
```



Returns TRUE if _BOOLEAN_ is TRUE; returns FALSE if _BOOLEAN_ is FALSE or UNKNOWN.



```
BOOLEAN.isFalse
```



Returns TRUE if _BOOLEAN_ is FALSE; returns FALSE if _BOOLEAN_ is TRUE or UNKNOWN.



```
BOOLEAN.isNotTrue
```



Returns TRUE if _BOOLEAN_ is FALSE or UNKNOWN; returns FALSE if _BOOLEAN_ is FALSE.



```
BOOLEAN.isNotFalse
```



 | Returns TRUE if _BOOLEAN_ is TRUE or UNKNOWN; returns FALSE if _BOOLEAN_ is FALSE. |

### Arithmetic Functions

| Arithmetic functions | Description |
| --- | --- |
| 



```
+ numeric
```



Returns _numeric_.



```
- numeric
```



Returns negative _numeric_.



```
numeric1 + numeric2
```



Returns _numeric1_ plus _numeric2_.



```
numeric1 - numeric2
```



Returns _numeric1_ minus _numeric2_.



```
numeric1 * numeric2
```



Returns _numeric1_ multiplied by _numeric2_.



```
numeric1 / numeric2
```



Returns _numeric1_ divided by _numeric2_.



```
POWER(numeric1, numeric2)
```



Returns _numeric1_ raised to the power of _numeric2_.



```
ABS(numeric)
```



Returns the absolute value of _numeric_.



```
MOD(numeric1, numeric2)
```



Returns the remainder (modulus) of _numeric1_ divided by _numeric2_. The result is negative only if _numeric1_ is negative.



```
SQRT(numeric)
```



Returns the square root of _numeric_.



```
LN(numeric)
```



Returns the natural logarithm (base e) of _numeric_.



```
LOG10(numeric)
```



Returns the base 10 logarithm of _numeric_.



```
LOG2(numeric)
```



Returns the base 2 logarithm of _numeric_.



```
LOG(numeric2)
LOG(numeric1, numeric2)
```



When called with one argument, returns the natural logarithm of _numeric2_. When called with two arguments, this function returns the logarithm of _numeric2_ to the base _numeric1_.**Note:** Currently, _numeric2_ must be greater than 0 and _numeric1_ must be greater than 1.



```
EXP(numeric)
```



Returns e raised to the power of _numeric_.



```
CEIL(numeric)
CEILING(numeric)
```



Rounds _numeric_ up, and returns the smallest number that is greater than or equal to _numeric_.



```
FLOOR(numeric)
```



Rounds _numeric_ down, and returns the largest number that is less than or equal to _numeric_.



```
SIN(numeric)
```



Returns the sine of _numeric_.



```
SINH(numeric)
```



Returns the hyperbolic sine of _numeric_.The return type is _DOUBLE_.



```
COS(numeric)
```



Returns the cosine of _numeric_.



```
TAN(numeric)
```



Returns the tangent of _numeric_.



```
TANH(numeric)
```



Returns the hyperbolic tangent of _numeric_.The return type is _DOUBLE_.



```
COT(numeric)
```



Returns the cotangent of a _numeric_.



```
ASIN(numeric)
```



Returns the arc sine of _numeric_.



```
ACOS(numeric)
```



Returns the arc cosine of _numeric_.



```
ATAN(numeric)
```



Returns the arc tangent of _numeric_.



```
ATAN2(numeric1, numeric2)
```



Returns the arc tangent of a coordinate _(numeric1, numeric2)_.



```
COSH(numeric)
```



Returns the hyperbolic cosine of _NUMERIC_.Return value type is _DOUBLE_.



```
DEGREES(numeric)
```



Returns the degree representation of a radian _numeric_.



```
RADIANS(numeric)
```



Returns the radian representation of a degree _numeric_.



```
SIGN(numeric)
```



Returns the signum of _numeric_.



```
ROUND(numeric, integer)
```



Returns a number rounded to _integer_ decimal places for _numeric_.



```
PI
```



Returns a value that is closer than any other values to pi.



```
E()
```



Returns a value that is closer than any other values to e.



```
RAND()
```



Returns a pseudorandom double value between 0.0 (inclusive) and 1.0 (exclusive).



```
RAND(integer)
```



Returns a pseudorandom double value between 0.0 (inclusive) and 1.0 (exclusive) with an initial seed _integer_. Two RAND functions will return identical sequences of numbers if they have the same initial seed.



```
RAND_INTEGER(integer)
```



Returns a pseudorandom integer value between 0 (inclusive) and _integer_ (exclusive).



```
RAND_INTEGER(integer1, integer2)
```



Returns a pseudorandom integer value between 0 (inclusive) and the specified value (exclusive) with an initial seed. Two RAND_INTEGER functions will return identical sequences of numbers if they have the same initial seed and bound.



```
UUID()
```



Returns an UUID (Universally Unique Identifier) string (e.g., "3d3c68f7-f608-473f-b60c-b0c44ad4cc4e") according to RFC 4122 type 4 (pseudo randomly generated) UUID. The UUID is generated using a cryptographically strong pseudo random number generator.



```
BIN(integer)
```



Returns a string representation of _integer_ in binary format. Returns NULL if _integer_ is NULL.E.g. `BIN(4)` returns '100' and `BIN(12)` returns '1100'.



```
HEX(numeric)
HEX(string) 
```



 | Returns a string representation of an integer _numeric_ value or a _string_ in hex format. Returns NULL if the argument is NULL.E.g. a numeric 20 leads to "14", a numeric 100 leads to "64", a string "hello,world" leads to "68656C6C6F2C776F726C64". |

| Arithmetic functions | Description |
| --- | --- |
| 



```
+ NUMERIC
```



Returns _NUMERIC_.



```
- NUMERIC
```



Returns negative _NUMERIC_.



```
NUMERIC1 + NUMERIC2
```



Returns _NUMERIC1_ plus _NUMERIC2_.



```
NUMERIC1 - NUMERIC2
```



Returns _NUMERIC1_ minus _NUMERIC2_.



```
NUMERIC1 * NUMERIC2
```



Returns _NUMERIC1_ multiplied by _NUMERIC2_.



```
NUMERIC1 / NUMERIC2
```



Returns _NUMERIC1_ divided by _NUMERIC2_.



```
NUMERIC1.power(NUMERIC2)
```



Returns _NUMERIC1_ raised to the power of _NUMERIC2_.



```
NUMERIC.abs()
```



Returns the absolute value of _NUMERIC_.



```
NUMERIC1 % NUMERIC2
```



Returns the remainder (modulus) of _NUMERIC1_ divided by _NUMERIC2_. The result is negative only if _numeric1_ is negative.



```
NUMERIC.sqrt()
```



Returns the square root of _NUMERIC_.



```
NUMERIC.ln()
```



Returns the natural logarithm (base e) of _NUMERIC_.



```
NUMERIC.log10()
```



Returns the base 10 logarithm of _NUMERIC_.



```
NUMERIC.log2()
```



Returns the base 2 logarithm of _NUMERIC_.



```
NUMERIC1.log()
NUMERIC1.log(NUMERIC2)
```



When called without argument, returns the natural logarithm of _NUMERIC1_. When called with an argument, returns the logarithm of _NUMERIC1_ to the base _NUMERIC2_.**Note:** Currently, _NUMERIC1_ must be greater than 0 and _NUMERIC2_ must be greater than 1.



```
NUMERIC.exp()
```



Returns e raised to the power of _NUMERIC_.



```
NUMERIC.ceil()
```



Rounds _NUMERIC_ up, and returns the smallest number that is greater than or equal to _NUMERIC_.



```
NUMERIC.floor()
```



Rounds _NUMERIC_ down, and returns the largest number that is less than or equal to _NUMERIC_.



```
NUMERIC.sin()
```



Returns the sine of _NUMERIC_.



```
NUMERIC.sinh()
```



Returns the hyperbolic sine of _NUMERIC_.The return type is _DOUBLE_.



```
NUMERIC.cos()
```



Returns the cosine of _NUMERIC_.



```
NUMERIC.tan()
```



Returns the tangent of _NUMERIC_.



```
NUMERIC.tanh()
```



Returns the hyperbolic tangent of _NUMERIC_.The return type is _DOUBLE_.



```
NUMERIC.cot()
```



Returns the cotangent of a _NUMERIC_.



```
NUMERIC.asin()
```



Returns the arc sine of _NUMERIC_.



```
NUMERIC.acos()
```



Returns the arc cosine of _NUMERIC_.



```
NUMERIC.atan()
```



Returns the arc tangent of _NUMERIC_.



```
atan2(NUMERIC1, NUMERIC2)
```



Returns the arc tangent of a coordinate _(NUMERIC1, NUMERIC2)_.



```
NUMERIC.cosh()
```



Returns the hyperbolic cosine of _NUMERIC_.Return value type is _DOUBLE_.



```
NUMERIC.degrees()
```



Returns the degree representation of a radian _NUMERIC_.



```
NUMERIC.radians()
```



Returns the radian representation of a degree _NUMERIC_.



```
NUMERIC.sign()
```



Returns the signum of _NUMERIC_.



```
NUMERIC.round(INT)
```



Returns a number rounded to _INT_ decimal places for _NUMERIC_.



```
pi()
```



Returns a value that is closer than any other values to pi.



```
e()
```



Returns a value that is closer than any other values to e.



```
rand()
```



Returns a pseudorandom double value between 0.0 (inclusive) and 1.0 (exclusive).



```
rand(INTEGER)
```



Returns a pseudorandom double value between 0.0 (inclusive) and 1.0 (exclusive) with an initial seed _INTEGER_. Two RAND functions will return identical sequences of numbers if they have the same initial seed.



```
randInteger(INTEGER)
```



Returns a pseudorandom integer value between 0 (inclusive) and _INTEGER_ (exclusive).



```
randInteger(INTEGER1, INTEGER2)
```



Returns a pseudorandom integer value between 0 (inclusive) and _INTEGER2_ (exclusive) with an initial seed _INTEGER1_. Two randInteger functions will return identical sequences of numbers if they have same initial seed and bound.



```
uuid()
```



Returns an UUID (Universally Unique Identifier) string (e.g., "3d3c68f7-f608-473f-b60c-b0c44ad4cc4e") according to RFC 4122 type 4 (pseudo randomly generated) UUID. The UUID is generated using a cryptographically strong pseudo random number generator.



```
INTEGER.bin()
```



Returns a string representation of _INTEGER_ in binary format. Returns NULL if _INTEGER_ is NULL.E.g., `4.bin()` returns "100" and `12.bin()` returns "1100".



```
NUMERIC.hex()
STRING.hex()
```



 | Returns a string representation of an integer _NUMERIC_ value or a _STRING_ in hex format. Returns NULL if the argument is NULL.E.g. a numeric 20 leads to "14", a numeric 100 leads to "64", a string "hello,world" leads to "68656C6C6F2C776F726C64". |

| Arithmetic functions | Description |
| --- | --- |
| 



```
+ NUMERIC
```



Returns _NUMERIC_.



```
- NUMERIC
```



Returns negative _NUMERIC_.



```
NUMERIC1 + NUMERIC2
```



Returns _NUMERIC1_ plus _NUMERIC2_.



```
NUMERIC1 - NUMERIC2
```



Returns _NUMERIC1_ minus _NUMERIC2_.



```
NUMERIC1 * NUMERIC2
```



Returns _NUMERIC1_ multiplied by _NUMERIC2_.



```
NUMERIC1 / NUMERIC2
```



Returns _NUMERIC1_ divided by _NUMERIC2_.



```
NUMERIC1.power(NUMERIC2)
```



Returns _NUMERIC1_ raised to the power of _NUMERIC2_.



```
NUMERIC.abs()
```



Returns the absolute value of _NUMERIC_.



```
NUMERIC1 % NUMERIC2
```



Returns the remainder (modulus) of _NUMERIC1_ divided by _NUMERIC2_. The result is negative only if _numeric1_ is negative.



```
NUMERIC.sqrt()
```



Returns the square root of _NUMERIC_.



```
NUMERIC.ln()
```



Returns the natural logarithm (base e) of _NUMERIC_.



```
NUMERIC.log10()
```



Returns the base 10 logarithm of _NUMERIC_.



```
NUMERIC.log2()
```



Returns the base 2 logarithm of _NUMERIC_.



```
NUMERIC1.log()
NUMERIC1.log(NUMERIC2)
```



When called without argument, returns the natural logarithm of _NUMERIC1_. When called with an argument, returns the logarithm of _NUMERIC1_ to the base _NUMERIC2_.**Note:** Currently, _NUMERIC1_ must be greater than 0 and _NUMERIC2_ must be greater than 1.



```
NUMERIC.exp()
```



Returns e raised to the power of _NUMERIC_.



```
NUMERIC.ceil()
```



Rounds _NUMERIC_ up, and returns the smallest number that is greater than or equal to _NUMERIC_.



```
NUMERIC.floor()
```



Rounds _NUMERIC_ down, and returns the largest number that is less than or equal to _NUMERIC_.



```
NUMERIC.sin()
```



Returns the sine of _NUMERIC_.



```
NUMERIC.sinh()
```



Returns the hyperbolic sine of _NUMERIC_.The return type is _DOUBLE_.



```
NUMERIC.cos()
```



Returns the cosine of _NUMERIC_.



```
NUMERIC.tan()
```



Returns the tangent of _NUMERIC_.



```
NUMERIC.tanh()
```



Returns the hyperbolic tangent of _NUMERIC_.The return type is _DOUBLE_.



```
NUMERIC.cot()
```



Returns the cotangent of a _NUMERIC_.



```
NUMERIC.asin()
```



Returns the arc sine of _NUMERIC_.



```
NUMERIC.acos()
```



Returns the arc cosine of _NUMERIC_.



```
NUMERIC.atan()
```



Returns the arc tangent of _NUMERIC_.



```
atan2(NUMERIC1, NUMERIC2)
```



Returns the arc tangent of a coordinate _(NUMERIC1, NUMERIC2)_.



```
NUMERIC.cosh()
```



Returns the hyperbolic cosine of _NUMERIC_.Return value type is _DOUBLE_.



```
NUMERIC.degrees()
```



Returns the degree representation of a radian _NUMERIC_.



```
NUMERIC.radians()
```



Returns the radian representation of a degree _NUMERIC_.



```
NUMERIC.sign()
```



Returns the signum of _NUMERIC_.



```
NUMERIC.round(INT)
```



Returns a number rounded to _INT_ decimal places for _NUMERIC_.



```
pi()
```



Returns a value that is closer than any other values to pi.



```
e()
```



Returns a value that is closer than any other values to e.



```
rand()
```



Returns a pseudorandom double value between 0.0 (inclusive) and 1.0 (exclusive).



```
rand(INTEGER)
```



Returns a pseudorandom double value between 0.0 (inclusive) and 1.0 (exclusive) with an initial seed _INTEGER_. Two RAND functions will return identical sequences of numbers if they have the same initial seed.



```
randInteger(INTEGER)
```



Returns a pseudorandom integer value between 0 (inclusive) and _INTEGER_ (exclusive).



```
randInteger(INTEGER1, INTEGER2)
```



Returns a pseudorandom integer value between 0 (inclusive) and _INTEGER2_ (exclusive) with an initial seed _INTEGER1_. Two randInteger functions will return identical sequences of numbers if they have same initial seed and bound.



```
uuid()
```



Returns an UUID (Universally Unique Identifier) string (e.g., "3d3c68f7-f608-473f-b60c-b0c44ad4cc4e") according to RFC 4122 type 4 (pseudo randomly generated) UUID. The UUID is generated using a cryptographically strong pseudo random number generator.



```
INTEGER.bin()
```



Returns a string representation of _INTEGER_ in binary format. Returns NULL if _INTEGER_ is NULL.E.g., `4.bin()` returns "100" and `12.bin()` returns "1100".



```
NUMERIC.hex()
STRING.hex()
```



 | Returns a string representation of an integer _NUMERIC_ value or a _STRING_ in hex format. Returns NULL if the argument is NULL.E.g. a numeric 20 leads to "14", a numeric 100 leads to "64", a string "hello,world" leads to "68656C6C6F2C776F726C64". |

### String Functions

| String functions | Description |
| --- | --- |
| 



```
string1 &#124;&#124; string2
```



Returns the concatenation of _string1_ and _string2_.



```
CHAR_LENGTH(string)
CHARACTER_LENGTH(string)
```



Returns the number of characters in _string_.



```
UPPER(string)
```



Returns _string_ in uppercase.



```
LOWER(string)
```



Returns _string_ in lowercase.



```
POSITION(string1 IN string2)
```



Returns the position (start from 1) of the first occurrence of _string1_ in _string2_; returns 0 if _string1_ cannot be found in _string2_.



```
TRIM([ BOTH &#124; LEADING &#124; TRAILING ] string1 FROM string2)
```



Returns a string that removes leading and/or trailing characters _string1_ from _string2_. By default, whitespaces at both sides are removed.



```
LTRIM(string)
```



Returns a string that removes the left whitespaces from _string_.E.g., `LTRIM(' This is a test String.')` returns "This is a test String.".



```
RTRIM(string)
```



Returns a string that removes the right whitespaces from _string_.E.g., `RTRIM('This is a test String. ')` returns "This is a test String.".



```
REPEAT(string, integer)
```



Returns a string that repeats the base _string_ _integer_ times.E.g., `REPEAT('This is a test String.', 2)` returns "This is a test String.This is a test String.".



```
REGEXP_REPLACE(string1, string2, string3)
```



Returns a string from _string1_ with all the substrings that match a regular expression _string2_ consecutively being replaced with _string3_.E.g., `REGEXP_REPLACE('foobar', 'oo&#124;ar', '')` returns "fb".



```
OVERLAY(string1 PLACING string2 FROM integer1 [ FOR integer2 ])
```



Returns a string that replaces _integer2_ (_string2_'s length by default) characters of _string1_ with _string2_ from position _integer1_.E.g., `OVERLAY('This is an old string' PLACING ' new' FROM 10 FOR 5)` returns "This is a new string"



```
SUBSTRING(string FROM integer1 [ FOR integer2 ])
```



Returns a substring of _string_ starting from position _integer1_ with length _integer2_ (to the end by default).



```
REPLACE(string1, string2, string3)
```



Returns a new string which replaces all the occurrences of _string2_ with _string3_ (non-overlapping) from _string1_E.g., `REPLACE("hello world", "world", "flink")` returns "hello flink"; `REPLACE("ababab", "abab", "z")` returns "zab".



```
REGEXP_EXTRACT(string1, string2[, integer])
```



Returns a string from _string1_ which extracted with a specified regular expression _string2_ and a regex match group index _integer_.**Note:** The regex match group index starts from 1 and 0 means matching the whole regex. In addition, the regex match group index should not exceed the number of the defined groups.E.g. `REGEXP_EXTRACT('foothebar', 'foo(.*?)(bar)', 2)"` returns "bar".



```
INITCAP(string)
```



Returns a new form of _string_ with the first character of each word converted to uppercase and the rest characters to lowercase. Here a word means a sequences of alphanumeric characters.



```
CONCAT(string1, string2,...)
```



Returns a string that concatenates _string1, string2, ..._. Returns NULL if any argument is NULL.E.g., `CONCAT('AA', 'BB', 'CC')` returns "AABBCC".



```
CONCAT_WS(string1, string2, string3,...)
```



Returns a string that concatenates _string2, string3, ..._ with a separator _string1_. The separator is added between the strings to be concatenated. Returns NULL If _string1_ is NULL. Compared with `CONCAT()`, `CONCAT_WS()` automatically skips NULL arguments.E.g., `CONCAT_WS('~', 'AA', NULL, 'BB', '', 'CC')` returns "AA~BB~~CC".



```
LPAD(string1, integer, string2)
```



Returns a new string from _string1_ left-padded with _string2_ to a length of _integer_ characters. If the length of _string1_ is shorter than _integer_, returns _string1_ shortened to _integer_ characters.E.g., `LPAD('hi',4,'??')` returns "??hi"; `LPAD('hi',1,'??')` returns "h".



```
RPAD(string1, integer, string2)
```



Returns a new string from _string1_ right-padded with _string2_ to a length of _integer_ characters. If the length of _string1_ is shorter than _integer_, returns _string1_ shortened to _integer_ characters.E.g., `RPAD('hi',4,'??')` returns "hi??", `RPAD('hi',1,'??')` returns "h".



```
FROM_BASE64(string)
```



Returns the base64-decoded result from _string_; returns NULL if _string_ is NULL.E.g., `FROM_BASE64('aGVsbG8gd29ybGQ=')` returns "hello world".



```
TO_BASE64(string)
```



 | Returns the base64-encoded result from _string_; returns NULL if _string_ is NULL.E.g., `TO_BASE64('hello world')` returns "aGVsbG8gd29ybGQ=". |

| String functions | Description |
| --- | --- |
| 



```
STRING1 + STRING2
```



Returns the concatenation of _STRING1_ and _STRING2_.



```
STRING.charLength()
```



Returns the number of characters in _STRING_.



```
STRING.upperCase()
```



Returns _STRING_ in uppercase.



```
STRING.lowerCase()
```



Returns _STRING_ in lowercase.



```
STRING1.position(STRING2)
```



Returns the position (start from 1) of the first occurrence of _STRING1_ in _STRING2_; returns 0 if _STRING1_ cannot be found in _STRING2_.



```
STRING1.trim(LEADING, STRING2)
STRING1.trim(TRAILING, STRING2)
STRING1.trim(BOTH, STRING2)
STRING1.trim(BOTH)
STRING1.trim()
```



Returns a string that removes leading and/or trailing characters _STRING2_ from _STRING1_. By default, whitespaces at both sides are removed.



```
STRING.ltrim()
```



Returns a string that removes the left whitespaces from _STRING_.E.g., `' This is a test String.'.ltrim()` returns "This is a test String.".



```
STRING.rtrim()
```



Returns a string that removes the right whitespaces from _STRING_.E.g., `'This is a test String. '.rtrim()` returns "This is a test String.".



```
STRING.repeat(INT)
```



Returns a string that repeats the base _STRING_ _INT_ times.E.g., `'This is a test String.'.repeat(2)` returns "This is a test String.This is a test String.".



```
STRING1.regexpReplace(STRING2, STRING3)
```



Returns a string from _STRING1_ with all the substrings that match a regular expression _STRING2_ consecutively being replaced with _STRING3_.E.g., `'foobar'.regexpReplace('oo&#124;ar', '')` returns "fb".



```
STRING1.overlay(STRING2, INT1)
STRING1.overlay(STRING2, INT1, INT2)
```



Returns a string that replaces _INT2_ (_STRING2_'s length by default) characters of _STRING1_ with _STRING2_ from position _INT1_.E.g., `'xxxxxtest'.overlay('xxxx', 6)` returns "xxxxxxxxx"; `'xxxxxtest'.overlay('xxxx', 6, 2)` returns "xxxxxxxxxst".



```
STRING.substring(INT1)
STRING.substring(INT1, INT2)
```



Returns a substring of _STRING_ starting from position _INT1_ with length _INT2_ (to the end by default).



```
STRING1.replace(STRING2, STRING3)
```



Returns a new string which replaces all the occurrences of _STRING2_ with _STRING3_ (non-overlapping) from _STRING1_.E.g., `'hello world'.replace('world', 'flink')` returns 'hello flink'; `'ababab'.replace('abab', 'z')` returns 'zab'.



```
STRING1.regexpExtract(STRING2[, INTEGER1])
```



Returns a string from _STRING1_ which extracted with a specified regular expression _STRING2_ and a regex match group index _INTEGER1_.**Note:** The regex match group index starts from 1 and 0 means matching the whole regex. In addition, the regex match group index should not exceed the number of the defined groups.E.g. `'foothebar'.regexpExtract('foo(.*?)(bar)', 2)"` returns "bar".



```
STRING.initCap()
```



Returns a new form of _STRING_ with the first character of each word converted to uppercase and the rest characters to lowercase. Here a word means a sequences of alphanumeric characters.



```
concat(STRING1, STRING2, ...)
```



Returns a string that concatenates _STRING1, STRING2, ..._. Returns NULL if any argument is NULL.E.g., `concat('AA', 'BB', 'CC')` returns "AABBCC".



```
concat_ws(STRING1, STRING2, STRING3, ...)
```



Returns a string that concatenates _STRING2, STRING3, ..._ with a separator _STRING1_. The separator is added between the strings to be concatenated. Returns NULL If _STRING1_ is NULL. Compared with `concat()`, `concat_ws()` automatically skips NULL arguments.E.g., `concat_ws('~', 'AA', Null(STRING), 'BB', '', 'CC')` returns "AA~BB~~CC".



```
STRING1.lpad(INT, STRING2)
```



Returns a new string from _STRING1_ left-padded with _STRING2_ to a length of _INT_ characters. If the length of _STRING1_ is shorter than _INT_, returns _STRING1_ shortened to _INT_ characters.E.g., `'hi'.lpad(4, '??')` returns "??hi"; `'hi'.lpad(1, '??')` returns "h".



```
STRING1.rpad(INT, STRING2)
```



Returns a new string from _STRING1_ right-padded with _STRING2_ to a length of _INT_ characters. If the length of _STRING1_ is shorter than _INT_, returns _STRING1_ shortened to _INT_ characters.E.g., `'hi'.rpad(4, '??')` returns "hi??"; `'hi'.rpad(1, '??')` returns "h".



```
STRING.fromBase64()
```



Returns the base64-decoded result from _STRING_; returns NULL if _STRING_ is NULL.E.g., `'aGVsbG8gd29ybGQ='.fromBase64()` returns "hello world".



```
STRING.toBase64()
```



 | Returns the base64-encoded result from _STRING_; returns NULL if _STRING_ is NULL.E.g., `'hello world'.toBase64()` returns "aGVsbG8gd29ybGQ=". |

| String functions | Description |
| --- | --- |
| 



```
STRING1 + STRING2
```



Returns the concatenation of _STRING1_ and _STRING2_.



```
STRING.charLength()
```



Returns the number of characters in _STRING_.



```
STRING.upperCase()
```



Returns _STRING_ in uppercase.



```
STRING.lowerCase()
```



Returns _STRING_ in lowercase.



```
STRING1.position(STRING2)
```



Returns the position (start from 1) of the first occurrence of _STRING1_ in _STRING2_; returns 0 if _STRING1_ cannot be found in _STRING2_.



```
STRING.trim(
  leading = true,
  trailing = true,
  character = " ")
```



Returns a string that removes leading and/or trailing characters from _STRING_.



```
STRING.ltrim()
```



Returns a string that removes the left whitespaces from _STRING_.E.g., `" This is a test String.".ltrim()` returns "This is a test String.".



```
STRING.rtrim()
```



Returns a string that removes the right whitespaces from _STRING_.E.g., `"This is a test String. ".rtrim()` returns "This is a test String.".



```
STRING.repeat(INT)
```



Returns a string that repeats the base _STRING_ _INT_ times.E.g., `"This is a test String.".repeat(2)` returns "This is a test String.This is a test String.".



```
STRING1.regexpReplace(STRING2, STRING3)
```



Returns a string from _STRING1_ with all the substrings that match a regular expression _STRING2_ consecutively being replaced with _STRING3_.E.g. `"foobar".regexpReplace("oo&#124;ar", "")` returns "fb".



```
STRING1.overlay(STRING2, INT1)
STRING1.overlay(STRING2, INT1, INT2)
```



Returns a string that replaces _INT2_ (_STRING2_'s length by default) characters of _STRING1_ with _STRING2_ from position _INT1_.E.g., `"xxxxxtest".overlay("xxxx", 6)` returns "xxxxxxxxx"; `"xxxxxtest".overlay("xxxx", 6, 2)` returns "xxxxxxxxxst".



```
STRING.substring(INT1)
STRING.substring(INT1, INT2)
```



Returns a substring of _STRING_ starting from position _INT1_ with length _INT2_ (to the end by default).



```
STRING1.replace(STRING2, STRING3)
```



Returns a new string which replaces all the occurrences of _STRING2_ with _STRING3_ (non-overlapping) from _STRING1_.E.g., `"hello world".replace("world", "flink")` returns "hello flink"; `"ababab".replace("abab", "z")` returns "zab".



```
STRING1.regexpExtract(STRING2[, INTEGER1])
```



Returns a string from _STRING1_ which extracted with a specified regular expression _STRING2_ and a regex match group index _INTEGER1_.**Note:** The regex match group index starts from 1 and 0 means matching the whole regex. In addition, the regex match group index should not exceed the number of the defined groups.E.g. `"foothebar".regexpExtract("foo(.*?)(bar)", 2)"` returns "bar".



```
STRING.initCap()
```



Returns a new form of _STRING_ with the first character of each word converted to uppercase and the rest characters to lowercase. Here a word means a sequences of alphanumeric characters.



```
concat(STRING1, STRING2, ...)
```



Returns a string that concatenates _STRING1, STRING2, ..._. Returns NULL if any argument is NULL.E.g., `concat("AA", "BB", "CC")` returns "AABBCC".



```
concat_ws(STRING1, STRING2, STRING3, ...)
```



Returns a string that concatenates _STRING2, STRING3, ..._ with a separator _STRING1_. The separator is added between the strings to be concatenated. Returns NULL If _STRING1_ is NULL. Compared with `concat()`, `concat_ws()` automatically skips NULL arguments.E.g., `concat_ws("~", "AA", Null(Types.STRING), "BB", "", "CC")` returns "AA~BB~~CC".



```
STRING1.lpad(INT, STRING2)
```



Returns a new string from _STRING1_ left-padded with _STRING2_ to a length of _INT_ characters. If the length of _STRING1_ is shorter than _INT_, returns _STRING1_ shortened to _INT_ characters.E.g., `"hi".lpad(4, "??")` returns "??hi"; `"hi".lpad(1, "??")` returns "h".



```
STRING1.rpad(INT, STRING2)
```



Returns a new string from _STRING1_ right-padded with _STRING2_ to a length of _INT_ characters. If the length of _STRING1_ is shorter than _INT_, returns _STRING1_ shortened to _INT_ characters.E.g., `"hi".rpad(4, "??")` returns "hi??"; `"hi".rpad(1, "??")` returns "h".



```
STRING.fromBase64()
```



Returns the base64-decoded result from _STRING_; returns null If _STRING_ is NULL.E.g., `"aGVsbG8gd29ybGQ=".fromBase64()` returns "hello world".



```
STRING.toBase64()
```



 | Returns the base64-encoded result from _STRING_; returns NULL if _STRING_ is NULL.E.g., `"hello world".toBase64()` returns "aGVsbG8gd29ybGQ=". |

### Temporal Functions

| Temporal functions | Description |
| --- | --- |
| 



```
DATE string
```



Returns a SQL date parsed from _string_ in form of "yyyy-MM-dd".



```
TIME string
```



Returns a SQL time parsed from _string_ in form of "HH:mm:ss".



```
TIMESTAMP string
```



Returns a SQL timestamp parsed from _string_ in form of "yyyy-MM-dd HH:mm:ss[.SSS]".



```
INTERVAL string range
```



Parses an interval _string_ in the form "dd hh:mm:ss.fff" for SQL intervals of milliseconds or "yyyy-mm" for SQL intervals of months. An interval range might be `DAY`, `MINUTE`, `DAY TO HOUR`, or `DAY TO SECOND` for intervals of milliseconds; `YEAR` or `YEAR TO MONTH` for intervals of months.E.g., `INTERVAL '10 00:00:00.004' DAY TO SECOND`, `INTERVAL '10' DAY`, or `INTERVAL '2-10' YEAR TO MONTH` return intervals.



```
CURRENT_DATE
```



Returns the current SQL date in the UTC time zone.



```
CURRENT_TIME
```



Returns the current SQL time in the UTC time zone.



```
CURRENT_TIMESTAMP
```



Returns the current SQL timestamp in the UTC time zone.



```
LOCALTIME
```



Returns the current SQL time in local time zone.



```
LOCALTIMESTAMP
```



Returns the current SQL timestamp in local time zone.



```
EXTRACT(timeintervalunit FROM temporal)
```



Returns a long value extracted from the _timeintervalunit_ part of _temporal_.E.g., `EXTRACT(DAY FROM DATE '2006-06-05')` returns 5.



```
YEAR(date)
```



Returns the year from SQL date _date_. Equivalent to EXTRACT(YEAR FROM date).E.g., `YEAR(DATE '1994-09-27')` returns 1994.



```
QUARTER(date)
```



Returns the quarter of a year (an integer between 1 and 4) from SQL date _date_. Equivalent to `EXTRACT(QUARTER FROM date)`.E.g., `QUARTER(DATE '1994-09-27')` returns 3.



```
MONTH(date)
```



Returns the month of a year (an integer between 1 and 12) from SQL date _date_. Equivalent to `EXTRACT(MONTH FROM date)`.E.g., `MONTH(DATE '1994-09-27')` returns 9.



```
WEEK(date)
```



Returns the week of a year (an integer between 1 and 53) from SQL date _date_. Equivalent to `EXTRACT(WEEK FROM date)`.E.g., `WEEK(DATE '1994-09-27')` returns 39.



```
DAYOFYEAR(date)
```



Returns the day of a year (an integer between 1 and 366) from SQL date _date_. Equivalent to `EXTRACT(DOY FROM date)`.E.g., `DAYOFYEAR(DATE '1994-09-27')` returns 270.



```
DAYOFMONTH(date)
```



Returns the day of a month (an integer between 1 and 31) from SQL date _date_. Equivalent to `EXTRACT(DAY FROM date)`.E.g., `DAYOFMONTH(DATE '1994-09-27')` returns 27.



```
DAYOFWEEK(date)
```



Returns the day of a week (an integer between 1 and 7; Sunday = 1) from SQL date _date_.Equivalent to `EXTRACT(DOW FROM date)`.E.g., `DAYOFWEEK(DATE '1994-09-27')` returns 3.



```
HOUR(timestamp)
```



Returns the hour of a day (an integer between 0 and 23) from SQL timestamp _timestamp_. Equivalent to `EXTRACT(HOUR FROM timestamp)`.E.g., `HOUR(TIMESTAMP '1994-09-27 13:14:15')` returns 13.



```
MINUTE(timestamp)
```



Returns the minute of an hour (an integer between 0 and 59) from SQL timestamp _timestamp_. Equivalent to `EXTRACT(MINUTE FROM timestamp)`.E.g., `MINUTE(TIMESTAMP '1994-09-27 13:14:15')` returns 14.



```
SECOND(timestamp)
```



Returns the second of a minute (an integer between 0 and 59) from SQL timestamp. Equivalent to `EXTRACT(SECOND FROM timestamp)`.E.g., `SECOND(TIMESTAMP '1994-09-27 13:14:15')` returns 15.



```
FLOOR(timepoint TO timeintervalunit)
```



Returns a value that rounds _timepoint_ down to the time unit _timeintervalunit_.E.g., `FLOOR(TIME '12:44:31' TO MINUTE)` returns 12:44:00.



```
CEIL(timepoint TO timeintervalunit)
```



Returns a value that rounds _timepoint_ up to the time unit _timeintervalunit_.E.g., `CEIL(TIME '12:44:31' TO MINUTE)` returns 12:45:00.



```
(timepoint1, temporal1) OVERLAPS (timepoint2, temporal2)
```



Returns TRUE if two time intervals defined by (_timepoint1_, _temporal1_) and (_timepoint2_, _temporal2_) overlap. The temporal values could be either a time point or a time interval.E.g., `(TIME '2:55:00', INTERVAL '1' HOUR) OVERLAPS (TIME '3:30:00', INTERVAL '2' HOUR)` returns TRUE; `(TIME '9:00:00', TIME '10:00:00') OVERLAPS (TIME '10:15:00', INTERVAL '3' HOUR)` returns FALSE.



```
DATE_FORMAT(timestamp, string)
```



Attention This function has serious bugs and should not be used for now. Please implement a custom UDF instead or use EXTRACT as a workaround.



```
TIMESTAMPADD(timeintervalunit, interval, timepoint)
```



Returns a new time value that adds a (signed) integer interval to _timepoint_. The unit for _interval_ is given by the unit argument, which should be one of the following values: `SECOND`, `MINUTE`, `HOUR`, `DAY`, `WEEK`, `MONTH`, `QUARTER`, or `YEAR`.E.g., `TIMESTAMPADD(WEEK, 1, DATE '2003-01-02')` returns `2003-01-09`.



```
TIMESTAMPDIFF(timepointunit, timepoint1, timepoint2)
```



 | Returns the (signed) number of _timepointunit_ between _timepoint1_ and _timepoint2_. The unit for the interval is given by the first argument, which should be one of the following values: `SECOND`, `MINUTE`, `HOUR`, `DAY`, `MONTH`, or `YEAR`. See also the [Time Interval and Point Unit Specifiers table](#time-interval-and-point-unit-specifiers).E.g., `TIMESTAMPDIFF(DAY, TIMESTAMP '2003-01-02 10:00:00', TIMESTAMP '2003-01-03 10:00:00')` leads to `1`. |

| Temporal functions | Description |
| --- | --- |
| 



```
STRING.toDate()
```



Returns a SQL date parsed from _STRING_ in form of "yyyy-MM-dd".



```
STRING.toTime()
```



Returns a SQL time parsed from _STRING_ in form of "HH:mm:ss".



```
STRING.toTimestamp()
```



Returns a SQL timestamp parsed from _STRING_ in form of "yyyy-MM-dd HH:mm:ss[.SSS]".



```
NUMERIC.year
NUMERIC.years
```



Creates an interval of months for _NUMERIC_ years.



```
NUMERIC.quarter
NUMERIC.quarters
```



Creates an interval of months for _NUMERIC_ quarters.E.g., `2.quarters` returns 6.



```
NUMERIC.month
NUMERIC.months
```



Creates an interval of _NUMERIC_ months.



```
NUMERIC.week
NUMERIC.weeks
```



Creates an interval of milliseconds for _NUMERIC_ weeks.E.g., `2.weeks` returns 1209600000.



```
NUMERIC.day
NUMERIC.days
```



Creates an interval of milliseconds for _NUMERIC_ days.



```
NUMERIC.hour
NUMERIC.hours
```



Creates an interval of milliseconds for _NUMERIC_ hours.



```
NUMERIC.minute
NUMERIC.minutes
```



Creates an interval of milliseconds for _NUMERIC_ minutes.



```
NUMERIC.second
NUMERIC.seconds
```



Creates an interval of milliseconds for _NUMERIC_ seconds.



```
NUMERIC.milli
NUMERIC.millis
```



Creates an interval of _NUMERIC_ milliseconds.



```
currentDate()
```



Returns the current SQL date in the UTC time zone.



```
currentTime()
```



Returns the current SQL time in the UTC time zone.



```
currentTimestamp()
```



Returns the current SQL timestamp in the UTC time zone.



```
localTime()
```



Returns the current SQL time in local time zone.



```
localTimestamp()
```



Returns the current SQL timestamp in local time zone.



```
TEMPORAL.extract(TIMEINTERVALUNIT)
```



Returns a long value extracted from the _TIMEINTERVALUNIT_ part of _temporal_.E.g., `'2006-06-05'.toDate.extract(DAY)` returns 5; `'2006-06-05'.toDate.extract(QUARTER)` returns 2.



```
TIMEPOINT.floor(TIMEINTERVALUNIT)
```



Returns a value that rounds _TIMEPOINT_ down to the time unit _TIMEINTERVALUNIT_.E.g., `'12:44:31'.toDate.floor(MINUTE)` returns 12:44:00.



```
TIMEPOINT.ceil(TIMEINTERVALUNIT)
```



Returns a value that rounds _TIMEPOINT_ up to the time unit _TIMEINTERVALUNIT_.E.g., `'12:44:31'.toTime.floor(MINUTE)` returns 12:45:00.



```
temporalOverlaps(TIMEPOINT1, TEMPORAL1, TIMEPOINT2, TEMPORAL2)
```



Returns TRUE if two time intervals defined by (_TIMEPOINT1_, _TEMPORAL1_) and (_TIMEPOINT2_, _TEMPORAL2_) overlap. The temporal values could be either a time point or a time interval.E.g., `temporalOverlaps('2:55:00'.toTime, 1.hour, '3:30:00'.toTime, 2.hour)` returns TRUE.



```
dateFormat(TIMESTAMP, STRING)
```



Attention This function has serious bugs and should not be used for now. Please implement a custom UDF instead or use extract() as a workaround.



```
timestampDiff(TIMEPOINTUNIT, TIMEPOINT1, TIMEPOINT2)
```



 | Returns the (signed) number of _TIMEPOINTUNIT_ between _TIMEPOINT1_ and _TIMEPOINT2_. The unit for the interval is given by the first argument, which should be one of the following values: `SECOND`, `MINUTE`, `HOUR`, `DAY`, `MONTH`, or `YEAR`. See also the [Time Interval and Point Unit Specifiers table](#time-interval-and-point-unit-specifiers).E.g., `timestampDiff(DAY, '2003-01-02 10:00:00'.toTimestamp, '2003-01-03 10:00:00'.toTimestamp)` leads to `1`. |

| Temporal functions | Description |
| --- | --- |
| 



```
STRING.toDate
```



Returns a SQL date parsed from _STRING_ in form of "yyyy-MM-dd".



```
STRING.toTime
```



Returns a SQL time parsed from _STRING_ in form of "HH:mm:ss".



```
STRING.toTimestamp
```



Returns a SQL timestamp parsed from _STRING_ in form of "yyyy-MM-dd HH:mm:ss[.SSS]".



```
NUMERIC.year
NUMERIC.years
```



Creates an interval of months for _NUMERIC_ years.



```
NUMERIC.quarter
NUMERIC.quarters
```



Creates an interval of months for _NUMERIC_ quarters.E.g., `2.quarters` returns 6.



```
NUMERIC.month
NUMERIC.months
```



Creates an interval of _NUMERIC_ months.



```
NUMERIC.week
NUMERIC.weeks
```



Creates an interval of milliseconds for _NUMERIC_ weeks.E.g., `2.weeks` returns 1209600000.



```
NUMERIC.day
NUMERIC.days
```



Creates an interval of milliseconds for _NUMERIC_ days.



```
NUMERIC.hour
NUMERIC.hours
```



Creates an interval of milliseconds for _NUMERIC_ hours.



```
NUMERIC.minute
NUMERIC.minutes
```



Creates an interval of milliseconds for _NUMERIC_ minutes.



```
NUMERIC.second
NUMERIC.seconds
```



Creates an interval of milliseconds for _NUMERIC_ seconds.



```
NUMERIC.milli
NUMERIC.millis
```



Creates an interval of _NUMERIC_ milliseconds.



```
currentDate()
```



Returns the current SQL date in the UTC time zone.



```
currentTime()
```



Returns the current SQL time in the UTC time zone.



```
currentTimestamp()
```



Returns the current SQL timestamp in the UTC time zone.



```
localTime()
```



Returns the current SQL time in local time zone.



```
localTimestamp()
```



Returns the current SQL timestamp in local time zone.



```
TEMPORAL.extract(TIMEINTERVALUNIT)
```



Returns a long value extracted from the _TIMEINTERVALUNIT_ part of _temporal_.E.g., `"2006-06-05".toDate.extract(TimeIntervalUnit.DAY)` returns 5; `"2006-06-05".toDate.extract(QUARTER)` returns 2.



```
TIMEPOINT.floor(TIMEINTERVALUNIT)
```



Returns a value that rounds _TIMEPOINT_ down to the time unit _TIMEINTERVALUNIT_.E.g., `"12:44:31".toDate.floor(TimeIntervalUnit.MINUTE)` returns 12:44:00.



```
TIMEPOINT.ceil(TIMEINTERVALUNIT)
```



Returns a value that rounds _TIMEPOINT_ up to the time unit _TIMEINTERVALUNIT_.E.g., `"12:44:31".toTime.floor(TimeIntervalUnit.MINUTE)` returns 12:45:00.



```
temporalOverlaps(TIMEPOINT1, TEMPORAL1, TIMEPOINT2, TEMPORAL2)
```



Returns TRUE if two time intervals defined by (_TIMEPOINT1_, _TEMPORAL1_) and (_TIMEPOINT2_, _TEMPORAL2_) overlap. The temporal values could be either a time point or a time interval.E.g., `temporalOverlaps("2:55:00".toTime, 1.hour, "3:30:00".toTime, 2.hour)` returns TRUE.



```
dateFormat(TIMESTAMP, STRING)
```



Attention This function has serious bugs and should not be used for now. Please implement a custom UDF instead or use extract() as a workaround.



```
timestampDiff(TIMEPOINTUNIT, TIMEPOINT1, TIMEPOINT2)
```



 | Returns the (signed) number of _TIMEPOINTUNIT_ between _TIMEPOINT1_ and _TIMEPOINT2_. The unit for the interval is given by the first argument, which should be one of the following values: `SECOND`, `MINUTE`, `HOUR`, `DAY`, `MONTH`, or `YEAR`. See also the [Time Interval and Point Unit Specifiers table](#time-interval-and-point-unit-specifiers).E.g., `timestampDiff(TimePointUnit.DAY, '2003-01-02 10:00:00'.toTimestamp, '2003-01-03 10:00:00'.toTimestamp)` leads to `1`. |

### Conditional Functions

| Conditional functions | Description |
| --- | --- |
| 



```
CASE value
WHEN value1_1 [, value1_2 ]* THEN result1
[ WHEN value2_1 [, value2_2 ]* THEN result2 ]*
[ ELSE resultZ ]
END
```



Returns _resultX_ when the first time _value_ is contained in (_valueX_1, valueX_2, ..._). When no value matches, returns _resultZ_ if it is provided and returns NULL otherwise.



```
CASE
WHEN condition1 THEN result1
[ WHEN condition2 THEN result2 ]*
[ ELSE resultZ ]
END
```



Returns _resultX_ when the first _conditionX_ is met. When no condition is met, returns _resultZ_ if it is provided and returns NULL otherwise.



```
NULLIF(value1, value2)
```



Returns NULL if _value1_ is equal to _value2_; returns _value1_ otherwise.E.g., `NULLIF(5, 5)` returns NULL; `NULLIF(5, 0)` returns 5.



```
COALESCE(value1, value2 [, value3 ]* )
```



 | Returns the first value that is not NULL from _value1, value2, ..._.E.g., `COALESCE(NULL, 5)` returns 5. |

| Conditional functions | Description |
| --- | --- |
| 



```
BOOLEAN.?(VALUE1, VALUE2)
```



 | Returns _VALUE1_ if _BOOLEAN_ evaluates to TRUE; returns _VALUE2_ otherwise.E.g., `(42 &gt; 5).?('A', 'B')` returns "A". |

| Conditional functions | Description |
| --- | --- |
| 



```
BOOLEAN.?(VALUE1, VALUE2)
```



 | Returns _VALUE1_ if _BOOLEAN_ evaluates to TRUE; returns _VALUE2_ otherwise.E.g., `(42 &gt; 5).?("A", "B")` returns "A". |

### Type Conversion Functions

| Type conversion functions | Description |
| --- | --- |
| 



```
CAST(value AS type)
```



 | Returns a new _value_ being cast to type _type_. See the supported types [here](sql.html#data-types).E.g., `CAST('42' AS INT)` returns 42; `CAST(NULL AS VARCHAR)` returns NULL of type VARCHAR. |

| Type conversion functions | Description |
| --- | --- |
| 



```
ANY.cast(TYPE)
```



 | Returns a new _ANY_ being cast to type _TYPE_. See the supported types [here](tableApi.html#data-types).E.g., `'42'.cast(INT)` returns 42; `Null(STRING)` returns NULL of type STRING. |

| Type conversion functions | Description |
| --- | --- |
| 



```
ANY.cast(TYPE)
```



 | Returns a new _ANY_ being cast to type _TYPE_. See the supported types [here](tableApi.html#data-types).E.g., `"42".cast(Types.INT)` returns 42; `Null(Types.STRING)` returns NULL of type STRING. |

### Collection Functions

| Collection functions | Description |
| --- | --- |
| 



```
CARDINALITY(array)
```



Returns the number of elements in _array_.



```
array ‘[’ integer ‘]’
```



Returns the element at position _integer_ in _array_. The index starts from 1.



```
ELEMENT(array)
```



Returns the sole element of _array_ (whose cardinality should be one); returns NULL if _array_ is empty. Throws an exception if _array_ has more than one element.



```
CARDINALITY(map)
```



Returns the number of entries in _map_.



```
map ‘[’ value ‘]’
```



 | Returns the value specified by key _value_ in _map_. |

| Collection functions | Description |
| --- | --- |
| 



```
ARRAY.cardinality()
```



Returns the number of elements in _ARRAY_.



```
ARRAY.at(INT)
```



Returns the element at position _INT_ in _ARRAY_. The index starts from 1.



```
ARRAY.element()
```



Returns the sole element of _ARRAY_ (whose cardinality should be one); returns NULL if _ARRAY_ is empty. Throws an exception if _ARRAY_ has more than one element.



```
MAP.cardinality()
```



Returns the number of entries in _MAP_.



```
MAP.at(ANY)
```



 | Returns the value specified by key _ANY_ in _MAP_. |

| Collection functions | Description |
| --- | --- |
| 



```
ARRAY.cardinality()
```



Returns the number of elements in _ARRAY_.



```
ARRAY.at(INT)
```



Returns the element at position _INT_ in _ARRAY_. The index starts from 1.



```
ARRAY.element()
```



Returns the sole element of _ARRAY_ (whose cardinality should be one); returns NULL if _ARRAY_ is empty. Throws an exception if _ARRAY_ has more than one element.



```
MAP.cardinality()
```



Returns the number of entries in _MAP_.



```
MAP.at(ANY)
```



 | Returns the value specified by key _ANY_ in _MAP_. |

### Value Construction Functions

| Value construction functions | Description |
| --- | --- |
| 



```
ROW(value1, [, value2]*)
(value1, [, value2]*)
```



Returns a row created from a list of values (_value1, value2,_...).



```
ARRAY ‘[’ value1 [, value2 ]* ‘]’
```



Returns an array created from a list of values (_value1, value2_, ...).



```
MAP ‘[’ value1, value2 [, value3, value4 ]* ‘]’
```



 | Returns a map created from a list of key-value pairs ((_value1, value2_), _(value3, value4)_, ...). |

| Value constructor functions | Description |
| --- | --- |
| 



```
row(ANY1, ANY2, ...)
```



Returns a row created from a list of object values (_ANY1, ANY2_, ...). Row is composite type that can be access via [value access functions](#value-access-functions).



```
array(ANY1, ANY2, ...)
```



Returns an array created from a list of object values (_ANY1, ANY2_, ...).



```
map(ANY1, ANY2, ANY3, ANY4, ...)
```



Returns a map created from a list of key-value pairs ((_ANY1, ANY2_), _(ANY3, ANY4)_, ...).



```
NUMERIC.rows
```



 | Creates a _NUMERIC_ interval of rows (commonly used in window creation). |

| Value constructor functions | Description |
| --- | --- |
| 



```
row(ANY1, ANY2, ...)
```



Returns a row created from a list of object values (_ANY1, ANY2_, ...). Row is composite type that can be access via [value access functions](#value-access-functions).



```
array(ANY1, ANY2, ...)
```



Returns an array created from a list of object values (_ANY1, ANY2_, ...).



```
map(ANY1, ANY2, ANY3, ANY4, ...)
```



Returns a map created from a list of key-value pairs ((_ANY1, ANY2_), _(ANY3, ANY4)_, ...).



```
NUMERIC.rows
```



 | Creates a _NUMERIC_ interval of rows (commonly used in window creation). |

### Value Access Functions

| Value access functions | Description |
| --- | --- |
| 



```
tableName.compositeType.field
```



Returns the value of a field from a Flink composite type (e.g., Tuple, POJO) by name.



```
tableName.compositeType.*
```



 | Returns a flat representation of a Flink composite type (e.g., Tuple, POJO) that converts each of its direct subtype into a separate field. In most cases the fields of the flat representation are named similarly to the original fields but with a dollar separator (e.g., `mypojo$mytuple$f0`). |

| Value access functions | Description |
| --- | --- |
| 



```
COMPOSITE.get(STRING)
COMPOSITE.get(INT)
```



Returns the value of a field from a Flink composite type (e.g., Tuple, POJO) by name or index.E.g., `pojo.get('myField')` or `tuple.get(0)`.



```
ANY.flatten()
```



 | Returns a flat representation of a Flink composite type (e.g., Tuple, POJO) that converts each of its direct subtype into a separate field. In most cases the fields of the flat representation are named similarly to the original fields but with a dollar separator (e.g., `mypojo$mytuple$f0`). |

| Value access functions | Description |
| --- | --- |
| 



```
COMPOSITE.get(STRING)
COMPOSITE.get(INT)
```



Returns the value of a field from a Flink composite type (e.g., Tuple, POJO) by name or index.E.g., `'pojo.get("myField")` or `'tuple.get(0)`.



```
ANY.flatten()
```



 | Returns a flat representation of a Flink composite type (e.g., Tuple, POJO) that converts each of its direct subtype into a separate field. In most cases the fields of the flat representation are named similarly to the original fields but with a dollar separator (e.g., `mypojo$mytuple$f0`). |

### Grouping Functions

| Grouping functions | Description |
| --- | --- |
| 



```
GROUP_ID()
```



Returns an integer that uniquely identifies the combination of grouping keys.



```
GROUPING(expression1 [, expression2]* )
GROUPING_ID(expression1 [, expression2]* )
```



 | Returns a bit vector of the given grouping expressions. |

| Grouping functions | Description |
| --- | --- |

| Grouping functions | Description |
| --- | --- |

### Hash Functions

| Hash functions | Description |
| --- | --- |
| 



```
MD5(string)
```



Returns the MD5 hash of _string_ as a string of 32 hexadecimal digits; returns NULL if _string_ is NULL.



```
SHA1(string)
```



Returns the SHA-1 hash of _string_ as a string of 40 hexadecimal digits; returns NULL if _string_ is NULL.



```
SHA224(string)
```



Returns the SHA-224 hash of _string_ as a string of 56 hexadecimal digits; returns NULL if _string_ is NULL.



```
SHA256(string)
```



Returns the SHA-256 hash of _string_ as a string of 64 hexadecimal digits; returns NULL if _string_ is NULL.



```
SHA384(string)
```



Returns the SHA-384 hash of _string_ as a string of 96 hexadecimal digits; returns NULL if _string_ is NULL.



```
SHA512(string)
```



Returns the SHA-512 hash of _string_ as a string of 128 hexadecimal digits; returns NULL if _string_ is NULL.



```
SHA2(string, hashLength)
```



 | Returns the hash using the SHA-2 family of hash functions (SHA-224, SHA-256, SHA-384, or SHA-512). The first argument _string_ is the string to be hashed and the second argument _hashLength_ is the bit length of the result (224, 256, 384, or 512). Returns NULL if _string_ or _hashLength_ is NULL. |

| Hash functions | Description |
| --- | --- |
| 



```
STRING.md5()
```



Returns the MD5 hash of _STRING_ as a string of 32 hexadecimal digits; returns NULL if _STRING_ is NULL.



```
STRING.sha1()
```



Returns the SHA-1 hash of _STRING_ as a string of 40 hexadecimal digits; returns NULL if _STRING_ is NULL.



```
STRING.sha224()
```



Returns the SHA-224 hash of _STRING_ as a string of 56 hexadecimal digits; returns NULL if _STRING_ is NULL.



```
STRING.sha256()
```



Returns the SHA-256 hash of _STRING_ as a string of 64 hexadecimal digits; returns NULL if _STRING_ is NULL.



```
STRING.sha384()
```



Returns the SHA-384 hash of _STRING_ as a string of 96 hexadecimal digits; returns NULL if _STRING_ is NULL.



```
STRING.sha512()
```



Returns the SHA-512 hash of _STRING_ as a string of 128 hexadecimal digits; returns NULL if _STRING_ is NULL.



```
STRING.sha2(INT)
```



 | Returns the SHA-2 family (SHA-224, SHA-256, SHA-384, or SHA-512) hashed value specified by _INT_ (which could be 224, 256, 384, or 512) for _STRING_. Returns NULL if _STRING_ or _INT_ is NULL. |

| Hash functions | Description |
| --- | --- |
| 



```
STRING.md5()
```



Returns the MD5 hash of _STRING_ as a string of 32 hexadecimal digits; returns NULL if _STRING_ is NULL.



```
STRING.sha1()
```



Returns the SHA-1 hash of _STRING_ as a string of 40 hexadecimal digits; returns NULL if _STRING_ is NULL.



```
STRING.sha224()
```



Returns the SHA-224 hash of _STRING_ as a string of 56 hexadecimal digits; returns NULL if _STRING_ is NULL.



```
STRING.sha256()
```



Returns the SHA-256 hash of _STRING_ as a string of 64 hexadecimal digits; returns NULL if _STRING_ is NULL.



```
STRING.sha384()
```



Returns the SHA-384 hash of _STRING_ as a string of 96 hexadecimal digits; returns NULL if _STRING_ is NULL.



```
STRING.sha512()
```



Returns the SHA-512 hash of _STRING_ as a string of 128 hexadecimal digits; returns NULL if _STRING_ is NULL.



```
STRING.sha2(INT)
```



 | Returns the SHA-2 family (SHA-224, SHA-256, SHA-384, or SHA-512) hashed value specified by _INT_ (which could be 224, 256, 384, or 512) for _STRING_. Returns NULL if _STRING_ or _INT_ is NULL. |

### Auxiliary Functions

| Auxiliary functions | Description |
| --- | --- |

| Auxiliary functions | Description |
| --- | --- |
| 



```
ANY.as(NAME1, NAME2, ...)
```



 | Specifies a name for _ANY_ (a field). Additional names can be specified if the expression expands to multiple fields. |

| Auxiliary functions | Description |
| --- | --- |
| 



```
ANY.as(NAME1, NAME2, ...)
```



 | Specifies a name for _ANY_ (a field). Additional names can be specified if the expression expands to multiple fields. |

## Aggregate Functions

The aggregate functions take an expression across all the rows as the input and return a single aggregated value as the result.

| Aggregate functions | Description |
| --- | --- |
| 



```
COUNT([ ALL ] expression &#124; DISTINCT expression1 [, expression2]*)
```



By default or with ALL, returns the number of input rows for which _expression_ is not NULL. Use DISTINCT for one unique instance of each value.



```
COUNT(*)
COUNT(1)
```



Returns the number of input rows.



```
AVG([ ALL &#124; DISTINCT ] expression)
```



By default or with keyword ALL, returns the average (arithmetic mean) of _expression_ across all input rows. Use DISTINCT for one unique instance of each value.



```
SUM([ ALL &#124; DISTINCT ] expression)
```



By default or with keyword ALL, returns the sum of _expression_ across all input rows. Use DISTINCT for one unique instance of each value.



```
MAX([ ALL &#124; DISTINCT ] expression)
```



By default or with keyword ALL, returns the maximum value of _expression_ across all input rows. Use DISTINCT for one unique instance of each value.



```
MIN([ ALL &#124; DISTINCT ] expression)
```



By default or with keyword ALL, returns the minimum value of _expression_ across all input rows. Use DISTINCT for one unique instance of each value.



```
STDDEV_POP([ ALL &#124; DISTINCT ] expression)
```



By default or with keyword ALL, returns the population standard deviation of _expression_ across all input rows. Use DISTINCT for one unique instance of each value.



```
STDDEV_SAMP([ ALL &#124; DISTINCT ] expression)
```



By default or with keyword ALL, returns the sample standard deviation of _expression_ across all input rows. Use DISTINCT for one unique instance of each value.



```
VAR_POP([ ALL &#124; DISTINCT ] expression)
```



By default or with keyword ALL, returns the population variance (square of the population standard deviation) of _expression_ across all input rows. Use DISTINCT for one unique instance of each value.



```
VAR_SAMP([ ALL &#124; DISTINCT ] expression)
```



By default or with keyword ALL, returns the sample variance (square of the sample standard deviation) of _expression_ across all input rows. Use DISTINCT for one unique instance of each value.



```
COLLECT([ ALL &#124; DISTINCT ] expression)
```



 | By default or with keyword ALL, returns a multiset of _expression_ across all input rows. NULL values will be ignored. Use DISTINCT for one unique instance of each value. |

| Aggregate functions | Description |
| --- | --- |
| 



```
FIELD.count
```



Returns the number of input rows for which _FIELD_ is not NULL.



```
FIELD.avg
```



Returns the average (arithmetic mean) of _FIELD_ across all input rows.



```
FIELD.sum
```



Returns the sum of numeric field _FIELD_ across all input rows. If all values are NULL, returns NULL.



```
FIELD.sum0
```



Returns the sum of numeric field _FIELD_ across all input rows. If all values are NULL, returns 0.



```
FIELD.max
```



Returns the maximum value of numeric field _FIELD_ across all input rows.



```
FIELD.min
```



Returns the minimum value of numeric field _FIELD_ across all input rows.



```
FIELD.stddevPop
```



Returns the population standard deviation of numeric field _FIELD_ across all input rows.



```
FIELD.stddevSamp
```



Returns the sample standard deviation of numeric field _FIELD_ across all input rows.



```
FIELD.varPop
```



Returns the population variance (square of the population standard deviation) of numeric field _FIELD_ across all input rows.



```
FIELD.varSamp
```



Returns the sample variance (square of the sample standard deviation) of numeric field _FIELD_ across all input rows.



```
FIELD.collect
```



 | Returns a multiset of _FIELD_ across all input rows. |

| Aggregate functions | Description |
| --- | --- |
| 



```
FIELD.count
```



Returns the number of input rows for which _FIELD_ is not NULL.



```
FIELD.avg
```



Returns the average (arithmetic mean) of _FIELD_ across all input rows.



```
FIELD.sum
```



Returns the sum of numeric field _FIELD_ across all input rows. If all values are NULL, returns NULL.



```
FIELD.sum0
```



Returns the sum of numeric field _FIELD_ across all input rows. If all values are NULL, returns 0.



```
FIELD.max
```



Returns the maximum value of numeric field _FIELD_ across all input rows.



```
FIELD.min
```



Returns the minimum value of numeric field _FIELD_ across all input rows.



```
FIELD.stddevPop
```



Returns the population standard deviation of numeric field _FIELD_ across all input rows.



```
FIELD.stddevSamp
```



Returns the sample standard deviation of numeric field _FIELD_ across all input rows.



```
FIELD.varPop
```



Returns the population variance (square of the population standard deviation) of numeric field _FIELD_ across all input rows.



```
FIELD.varSamp
```



Returns the sample variance (square of the sample standard deviation) of numeric field _FIELD_ across all input rows.



```
FIELD.collect
```



 | Returns a multiset of _FIELD_ across all input rows. |

## Date Format Specifiers

The following table lists specifiers for date format functions.

| Specifier | Description |
| --- | --- |
| 



```
%a
```



Abbreviated weekday name (`Sun` .. `Sat`)



```
%b
```



Abbreviated month name (`Jan` .. `Dec`)



```
%c
```



Month, numeric (`1` .. `12`)



```
%D
```



Day of the month with English suffix (`0th`, `1st`, `2nd`, `3rd`, ...)



```
%d
```



Day of the month, numeric (`01` .. `31`)



```
%e
```



Day of the month, numeric (`1` .. `31`)



```
%f
```



Fraction of second (6 digits for printing: `000000` .. `999000`; 1 - 9 digits for parsing: `0` .. `999999999`) (Timestamp is truncated to milliseconds.)



```
%H
```



Hour (`00` .. `23`)



```
%h
```



Hour (`01` .. `12`)



```
%I
```



Hour (`01` .. `12`)



```
%i
```



Minutes, numeric (`00` .. `59`)



```
%j
```



Day of year (`001` .. `366`)



```
%k
```



Hour (`0` .. `23`)



```
%l
```



Hour (`1` .. `12`)



```
%M
```



Month name (`January` .. `December`)



```
%m
```



Month, numeric (`01` .. `12`)



```
%p
```



`AM` or `PM`



```
%r
```



Time, 12-hour (`hh:mm:ss` followed by `AM` or `PM`)



```
%S
```



Seconds (`00` .. `59`)



```
%s
```



Seconds (`00` .. `59`)



```
%T
```



Time, 24-hour (`hh:mm:ss`)



```
%U
```



Week (`00` .. `53`), where Sunday is the first day of the week



```
%u
```



Week (`00` .. `53`), where Monday is the first day of the week



```
%V
```



Week (`01` .. `53`), where Sunday is the first day of the week; used with `%X`



```
%v
```



Week (`01` .. `53`), where Monday is the first day of the week; used with `%x`



```
%W
```



Weekday name (`Sunday` .. `Saturday`)



```
%w
```



Day of the week (`0` .. `6`), where Sunday is the first day of the week



```
%X
```



Year for the week where Sunday is the first day of the week, numeric, four digits; used with `%V`



```
%x
```



Year for the week, where Monday is the first day of the week, numeric, four digits; used with `%v`



```
%Y
```



Year, numeric, four digits



```
%y
```



Year, numeric (two digits)



```
%%
```



A literal `%` character



```
%x
```



 | `x`, for any `x` not listed above |

## Time Interval and Point Unit Specifiers

The following table lists specifiers for time interval and time point units.

For Table API, please use `_` for spaces (e.g., `DAY_TO_HOUR`).

| Time Interval Unit | Time Point Unit |
| --- | --- |
| `MILLENIUM` _(SQL-only)_ |   |
| `CENTURY` _(SQL-only)_ |   |
| `YEAR` | `YEAR` |
| `YEAR TO MONTH` |   |
| `QUARTER` | `QUARTER` |
| `MONTH` | `MONTH` |
| `WEEK` | `WEEK` |
| `DAY` | `DAY` |
| `DAY TO HOUR` |   |
| `DAY TO MINUTE` |   |
| `DAY TO SECOND` |   |
| `HOUR` | `HOUR` |
| `HOUR TO MINUTE` |   |
| `HOUR TO SECOND` |   |
| `MINUTE` | `MINUTE` |
| `MINUTE TO SECOND` |   |
| `SECOND` | `SECOND` |
|   | `MILLISECOND` |
|   | `MICROSECOND` |
| `DOY` _(SQL-only)_ |   |
| `DOW` _(SQL-only)_ |   |
|   | `SQL_TSI_YEAR` _(SQL-only)_ |
|   | `SQL_TSI_QUARTER` _(SQL-only)_ |
|   | `SQL_TSI_MONTH` _(SQL-only)_ |
|   | `SQL_TSI_WEEK` _(SQL-only)_ |
|   | `SQL_TSI_DAY` _(SQL-only)_ |
|   | `SQL_TSI_HOUR` _(SQL-only)_ |
|   | `SQL_TSI_MINUTE` _(SQL-only)_ |
|   | `SQL_TSI_SECOND` _(SQL-only)_ |

