All Products
Search
Document Center

Realtime Compute for Apache Flink:Supported functions

Last Updated:Mar 26, 2026

Realtime Compute for Apache Flink supports three categories of built-in functions: scalar functions, table-valued functions, and aggregate functions. If the built-in functions don't cover your use case, use user-defined functions (UDFs) instead.

The following tables list all built-in functions available in Realtime Compute for Apache Flink based on Apache Flink 1.15. The available functions vary by Apache Flink version — see the official documentation for 1.12, 1.13, 1.14, 1.15, 1.16, and 1.17. Ververica Runtime (VVR) 3.0.0 also adds extra built-in functions beyond those in Apache Flink 1.12 — see Scalar functions, Table-valued functions, and Aggregate functions.

Limitations

VVR 11.1 and later supports calling built-in functions in Table API jobs using SQL text.

Scalar functions

Comparison functions

Function Description
value1 = value2 Returns TRUE if value1 equals value2.
value1 \<\> value2 Returns TRUE if value1 does not equal value2.
value1 \> value2 Returns TRUE if value1 is greater than value2.
value1 \>= value2 Returns TRUE if value1 is greater than or equal to value2.
value1 \< value2 Returns TRUE if value1 is less than value2.
value1 \<= value2 Returns TRUE if value1 is less than or equal to value2.
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 value1 and value2 differ in data type or value. NULL values are treated as equal.
value1 IS NOT DISTINCT FROM value2 Returns TRUE if value1 and value2 have the same data type and value. NULL values are treated as equal.
value1 BETWEEN \[ASYMMETRIC | SYMMETRIC\] value2 AND value3 By default (or with ASYMMETRIC), returns TRUE if value1 is between value2 and value3 (inclusive).
value1 NOT BETWEEN \[ASYMMETRIC | SYMMETRIC\] value2 AND value3 By default (or with ASYMMETRIC), returns TRUE if value1 is less than value2 or greater than value3.
string1 LIKE string2 \[ESCAPE char\] Returns TRUE if string1 matches pattern string2.
string1 NOT LIKE string2 \[ESCAPE char\] Returns TRUE if string1 does not match pattern string2.
string1 SIMILAR TO string2 \[ESCAPE char\] Returns TRUE if string1 matches SQL regular expression string2.
string1 NOT SIMILAR TO string2 \[ESCAPE char\] Returns TRUE if string1 does not match SQL regular expression string2.
value1 IN (value2 \[, value3\]\*) Returns TRUE if value1 exists in the list.
value1 NOT IN (value2 \[, value3\]\*) Returns TRUE if value1 does not exist in the list.
EXISTS (sub-query) Returns TRUE if the subquery returns at least one row.
value IN (sub-query) Returns TRUE if value equals a row in the subquery result set.
value NOT IN (sub-query) Returns TRUE if value is not in any row returned by the subquery.

Logical functions

Function Description
BITAND Performs a bitwise AND operation.
BITNOT Performs a bitwise NOT operation.
BITOR Performs a bitwise OR operation.
BITXOR Performs a bitwise XOR operation.
boolean1 OR boolean2 Returns TRUE if boolean1 or boolean2 is TRUE.
boolean1 AND boolean2 Returns TRUE if both boolean1 and boolean2 are TRUE.
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 TRUE.
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.

Arithmetic functions

Function Description
+ numeric Returns the numeric value.
- numeric Returns the negation of numeric.
numeric1 + numeric2 Returns the sum of numeric1 and numeric2.
numeric1 - numeric2 Returns the difference of numeric1 and numeric2.
numeric1 \* numeric2 Returns the product of numeric1 and numeric2.
numeric1 / numeric2 Returns the quotient of numeric1 divided by numeric2.
numeric1 % numeric2 Returns the remainder of numeric1 divided by numeric2.
POWER(numeric1, numeric2) Returns numeric1 raised to the power of numeric2.
ABS(numeric) Returns the absolute value of numeric.
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) With one argument, returns the natural logarithm of numeric2. With two arguments, returns the base-numeric1 logarithm of numeric2. Requires numeric2 > 0 and numeric1 > 1.
EXP(numeric) Returns e raised to the power of numeric.
CEIL(numeric) | CEILING(numeric) Rounds numeric up to the nearest integer.
FLOOR(numeric) Rounds numeric down to the nearest integer.
SIN(numeric) Returns the sine of numeric.
SINH(numeric) Returns the hyperbolic sine of numeric. Returns DOUBLE.
COS(numeric) Returns the cosine of numeric.
TAN(numeric) Returns the tangent of numeric.
TANH(numeric) Returns the hyperbolic tangent of numeric. Returns DOUBLE.
COT(numeric) Returns the cotangent of numeric.
ASIN(numeric) Returns the arcsine of numeric.
ACOS(numeric) Returns the arccosine of numeric.
ATAN(numeric) Returns the arctangent of numeric.
ATAN2(numeric1, numeric2) Returns the arctangent of coordinate (numeric1, numeric2).
COSH(numeric) Returns the hyperbolic cosine of numeric. Returns DOUBLE.
DEGREES(numeric) Converts radians to degrees.
RADIANS(numeric) Converts degrees to radians.
SIGN(numeric) Returns the sign of numeric.
ROUND(numeric, INT) Rounds numeric to INT decimal places.
PI() Returns a value close to π.
E() Returns a value close to e.
RAND() Returns a pseudorandom double in [0.0, 1.0).
RAND(INT) Returns a pseudorandom double in [0.0, 1.0) with seed INT.
RAND_INTEGER(INT) Returns a pseudorandom integer in [0, INT).
RAND_INTEGER(INT1, INT2) Returns a pseudorandom integer in [0, INT2) with seed INT1.
UUID() Returns a pseudorandom UUID string (RFC 4122 Type 4).
BIN(INT) Returns the binary string representation of INT.
HEX(numeric) | HEX(string) Returns the hexadecimal string representation of a number or string.
TRUNCATE(numeric1, integer2) Truncates numeric1 to integer2 decimal places.
UNHEX(expr) Converts a hexadecimal string to BINARY.
PERCENTILE(expr, percentage\[, frequency\]) Returns the exact percentile value of expr at the specified percentage.

String functions

Function Description
string1 || 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 (1-based) of the first occurrence of string1 in string2. Returns 0 if not found.
TRIM(\[BOTH | LEADING | TRAILING\] string1 FROM string2) Removes leading, trailing, or both occurrences of string1 from string2. For example, TRIM(TRAILING 'fe' FROM 'abcdef') returns 'abcd'.
LTRIM(string) Removes leading spaces from string.
RTRIM(string) Removes trailing spaces from string.
REPEAT(string, int) Returns string repeated int times.
REGEXP_REPLACE Replaces occurrences of a pattern in a string and returns the result.
OVERLAY(string1 PLACING string2 FROM integer1 \[FOR integer2\]) Replaces integer2 characters in string1 starting at integer1 with string2. Defaults integer2 to the length of string2.
SUBSTRING(string FROM integer1 \[FOR integer2\]) Returns a substring of string starting at integer1. If integer2 is specified, limits the length to integer2 characters.
REPLACE(string1, string2, string3) Replaces all non-overlapping occurrences of string2 in string1 with string3.
REGEXP_EXTRACT(string1, string2\[, integer\]) Splits string1 using regular expression string2 and returns the substring at position integer.
INITCAP(string) Capitalizes the first letter of each word and lowercases the rest.
CONCAT(string1, string2, ...) Concatenates multiple strings. Returns NULL if any input is NULL.
CONCAT_WS(string1, string2, string3, ...) Concatenates string2, string3, ... with separator string1.
LPAD(string1, integer, string2) Pads string1 on the left with string2 until it reaches length integer.
RPAD(string1, integer, string2) Pads string1 on the right with string2 until it reaches length integer.
FROM_BASE64(string) Decodes a Base64-encoded string.
TO_BASE64(string) Encodes string using Base64.
ASCII(string) Returns the ASCII code of the first character in string.
CHR(integer) Returns the ASCII character corresponding to integer.
DECODE(binary, string) Decodes binary using the specified encoding (US-ASCII, ISO-8859-1, UTF-8, UTF-16BE, UTF-16LE, or UTF-16).
ENCODE(string1, string2) Encodes string1 using the encoding specified by string2 (US-ASCII, ISO-8859-1, UTF-8, UTF-16BE, UTF-16LE, or UTF-16).
INSTR(string1, string2) Returns the position of the first occurrence of string2 in string1.
LEFT(string, integer) Returns the leftmost integer characters of string.
RIGHT(string, integer) Returns the rightmost integer characters of string.
LOCATE(string1, string2\[, integer\]) Returns the position of the first occurrence of string1 in string2, starting from integer.
PARSE_URL Parses a specific part of a URL and returns the value.
REGEXP Searches for a regular expression pattern in a string and returns a boolean.
REGEXP_SUBSTR(str, regex) Returns the first substring in str that matches regex.
REGEXP_INSTR(str, regex) Returns the position of the first substring in str that matches regex.
REGEXP_COUNT(str, regex) Returns the number of times str matches regex.
REGEXP_EXTRACT_ALL(str, regex\[, extractIndex\]) Extracts all substrings in str that match regex and correspond to group extractIndex.
REVERSE(string) Returns string in reverse order.
SPLIT_INDEX Splits a string by a delimiter and returns the element at a specified position.
STR_TO_MAP(string1\[, string2, string3\]) Splits string1 into key-value pairs using delimiters and returns a map.
[SUBSTR(string\[, integer1\[, integer2\]\])](https://nightlies.apache.org/flink/flink-docs-release-1.17/docs/dev/table/functions/systemfunctions/#string-functions) Returns a substring of string starting at integer1 with length integer2.
PRINTF(format\[, obj\]\*) Returns a formatted string using printf-style formatting.
TRANSLATE(expr, fromStr, toStr) Replaces each character in fromStr with the corresponding character in toStr.
ELT(index, expr\[, exprs\]\*) Returns the expression at position index (1-based).
BTRIM(str\[, trimStr\]) Removes leading and trailing characters in trimStr from str. Defaults to whitespace.
STARTSWITH(expr, startExpr) Returns TRUE if expr starts with startExpr. Returns TRUE if startExpr is empty.
ENDSWITH(expr, endExpr) Returns TRUE if expr ends with endExpr. Returns TRUE if endExpr is empty.

Time functions

Function Description
DATE string Returns a SQL DATE value parsed from a string in yyyy-MM-dd format.
DATEDIFF Calculates the difference between two date values.
DATE_ADD Returns a date that is a specified number of days after a given date.
DATE_SUB Returns a date that is a specified number of days before a given date.
TIME string Returns a SQL TIME value parsed from a string in HH:mm:ss format.
TIMESTAMP string Returns a SQL TIMESTAMP value parsed from a string in yyyy-MM-dd HH:mm:ss[.SSS] format.
INTERVAL string range Parses intervals in milliseconds from dd hh:mm:ss.fff format or in months from yyyy-mm format.
LOCALTIME Returns the current local time as SQL TIME(0).
LOCALTIMESTAMP Returns the current local timestamp as SQL TIMESTAMP(3).
CURRENT_TIME Returns the current local time as SQL TIME. Equivalent to LOCALTIME.
CURRENT_DATE Returns the current local date as SQL DATE.
CURRENT_TIMESTAMP Returns the current local timestamp as SQL TIMESTAMP.
NOW() Returns the current local timestamp as SQL TIMESTAMP. Equivalent to CURRENT_TIMESTAMP.
CURRENT_ROW_TIMESTAMP() Returns the current local timestamp as SQL TIMESTAMP.
EXTRACT(timeintervalunit FROM temporal) Extracts a LONG value for the specified timeintervalunit from temporal.
YEAR(date) Returns the year component of a SQL DATE value.
QUARTER(date) Returns the quarter component of a SQL DATE value.
MONTH(date) Returns the month component of a SQL DATE value.
WEEK(date) Returns the week-of-year number for a SQL DATE value.
DAYOFYEAR(date) Returns the day-of-year number for a SQL DATE value.
DAYOFMONTH(date) Returns the day-of-month number for a SQL DATE value.
HOUR(timestamp) Returns the hour component of a SQL TIMESTAMP value.
MINUTE(timestamp) Returns the minute component of a SQL TIMESTAMP value.
SECOND(timestamp) Returns the second component of a SQL TIMESTAMP value.
FLOOR(timepoint TO timeintervalunit) Rounds timepoint down to the nearest timeintervalunit.
CEIL(timepoint TO timeintervalunit) Rounds timepoint up to the nearest timeintervalunit.
(timepoint1, temporal1) OVERLAPS (timepoint2, temporal2) Returns TRUE if the two time intervals overlap.
DATE_FORMAT Formats a STRING date value using a specified pattern.
DATE_FORMAT_TZ Formats a TIMESTAMP value as a STRING in a specified time zone and format.
TIMESTAMPADD(timeintervalunit, interval, timepoint) Adds an interval to timepoint and returns the new timepoint.
TIMESTAMPDIFF(timepointunit, timepoint1, timepoint2) Returns the time interval between timepoint1 and timepoint2.
CONVERT_TZ(string1, string2, string3) Converts datetime string1 from time zone string2 to time zone string3. Expects yyyy-MM-dd HH:mm:ss format.
FROM_UNIXTIME Returns a VARCHAR date value from a Unix timestamp.
UNIX_TIMESTAMP Converts a date value to a Unix timestamp.
TO_DATE Converts an INT or VARCHAR date value to the DATE data type.
TO_TIMESTAMP_LTZ(numeric, precision) Converts a Unix timestamp to TIMESTAMP_LTZ (milliseconds or seconds).
TO_TIMESTAMP(string1\[, string2\]) Converts string1 in UTC+0 to a timestamp. Defaults format string2 to yyyy-MM-dd HH:mm:ss.
TO_TIMESTAMP_TZ Converts a VARCHAR date value to a TIMESTAMP in a specified time zone.
CURRENT_WATERMARK(rowtime) Returns the current watermark for the rowtime column.

Conditional functions

Function Description
CASE value WHEN value1\_1 \[, value1\_2\]\* THEN result1 (WHEN value2\_1 \[, value2\_2\]\* THEN result2)\* (ELSE result\_z) END Returns resultX if value matches any value in the valueX list.
CASE WHEN condition1 THEN result1 (WHEN condition2 THEN result2)\* (ELSE result\_z) END Returns resultX for the first conditionX that is TRUE.
NULLIF(value1, value2) Returns NULL if value1 equals value2; otherwise returns value1.
COALESCE(value1, value2\[, value3\]\*) Returns the first non-NULL value among the arguments.
IF(condition, true\_value, false\_value) Returns true\_value if condition is TRUE; otherwise returns false\_value.
IFNULL(input, null\_replacement) Returns null\_replacement if input is NULL; otherwise returns input.
IS_ALPHA(string) Returns TRUE if all characters in string are letters.
IS_DECIMAL(string) Returns TRUE if string can be parsed as a valid number.
IS_DIGIT(string) Returns TRUE if all characters in string are digits.
GREATEST(value1\[, value2\]\*) Returns the maximum value among the arguments. Returns NULL if any input is NULL.
LEAST(value1\[, value2\]\*) Returns the minimum value among the arguments. Returns NULL if any input is NULL.

Data type conversion functions

Function Description
CONV Converts numeric values or characters between bases.
CAST(value AS type) Converts value to the specified type.
TYPEOF(input) | TYPEOF(input, force\_serializable) Returns the string representation of the data type of input.

Collection functions

Function Description
CARDINALITY(array) Returns the number of elements in array.
array\[INT\] Returns the element at position INT in array.
ELEMENT(array) Returns the only element of array if its cardinality is 1.
CARDINALITY(map) Returns the number of entries in map.
map\[value\] Returns the value associated with the specified key in the map.

JSON functions

Function Description
IS JSON \[{ VALUE | SCALAR | ARRAY | OBJECT }\] Returns TRUE if the input is a valid JSON string.
JSON_EXISTS(jsonValue, path \[{ TRUE | FALSE | UNKNOWN | ERROR } ON ERROR\]) Returns TRUE if a JSON string satisfies the specified path condition.
JSON_STRING(value) Serializes value into a JSON string.
JSON_VALUE Extracts a scalar value at the specified path from a JSON string.
JSON_QUERY(jsonValue, path \[wrapper\] \[ON EMPTY\] \[ON ERROR\]) Extracts a JSON value from a JSON string.
[JSON_OBJECT(\[\[KEY\] key VALUE value\]\* \[{ NULL | ABSENT } ON NULL\])](https://nightlies.apache.org/flink/flink-docs-release-1.17/docs/dev/table/functions/systemfunctions/#json-functions) Builds a JSON object from key-value pairs.
JSON_OBJECTAGG(\[KEY\] key VALUE value \[{ NULL | ABSENT } ON NULL\]) Aggregates key-value expressions into a JSON object.
JSON_ARRAY(\[value\]\* \[{ NULL | ABSENT } ON NULL\]) Builds a JSON array from a list of values.
JSON_ARRAYAGG(items \[{ NULL | ABSENT } ON NULL\]) Aggregates items into a JSON array string.
JSON_QUOTE Wraps a string in double quotes as a JSON value.
JSON_UNQUOTE Removes JSON quoting from a value.

Value construction functions

Function Description
(value1 \[, value2\]\*) Returns a row constructed from the given values.
[ARRAY\[value1 \[, value2\]\*\]](https://nightlies.apache.org/flink/flink-docs-release-1.17/docs/dev/table/functions/systemfunctions/#value-construction-functions) Returns an array constructed from the given values.
[MAP\[value1, value2 \[, value3, value4\]\*\]](https://nightlies.apache.org/flink/flink-docs-release-1.17/docs/dev/table/functions/systemfunctions/#value-construction-functions) Returns a map constructed from the given key-value pairs.

Value acquisition functions

Function Description
tableName.compositeType.field Extracts a field value from a composite type such as Tuple or POJO.
tableName.compositeType.\* Expands a composite type such as Tuple or POJO into separate fields.

Grouping functions

Function Description
GROUP_ID() Returns an integer that uniquely identifies a combination of grouping keys.
GROUPING(expression1 \[, expression2\]\*) | GROUPING_ID(expression1 \[, expression2\]\*) Returns a bit vector representing the grouping status of the given expressions.

Hash functions

Function Description
MD5(string) Returns the MD5 hash of string as a 32-character hexadecimal string.
SHA1(string) Returns the SHA-1 hash of string as a 40-character hexadecimal string.
SHA224(string) Returns the SHA-224 hash of string as a 56-character hexadecimal string.
SHA256(string) Returns the SHA-256 hash of string as a 64-character hexadecimal string.
SHA384(string) Returns the SHA-384 hash of string as a 96-character hexadecimal string.
SHA512(string) Returns the SHA-512 hash of string as a 128-character hexadecimal string.
SHA2(string, hashLength) Returns a hash using SHA-224, SHA-256, SHA-384, or SHA-512, depending on hashLength.
MURMUR_HASH Calculates the 32-bit Murmur hash of the input.
MURMUR_HASH_64 Calculates the 64-bit Murmur hash of the input using the Murmur 128 algorithm.

Other scalar functions

Function Description
ISNAN Returns TRUE if the specified floating-point number is NaN (equivalent to Double.isNaN() or Float.isNaN() in Java).
KEYVALUE Splits a string into key-value pairs using split1 as the pair delimiter and split2 as the key-value delimiter, then returns the value for the specified key.

Table-valued functions

Function Description
GENERATE_SERIES Generates a series of values following the pattern from, from+1, from+2 ... to-1.
JSON_TUPLE Extracts values at each specified path from a JSON string.
MULTI_KEYVALUE Splits a string into key-value pairs using split1 as the pair delimiter and split2 as the key-value delimiter, then returns the values for specified keys.
STRING_SPLIT Splits a string into substrings using a specified delimiter and returns them as a list.

Aggregate functions

Note

Starting from VVR 11.6, the variance and standard deviation functions use improved algorithms for better calculation accuracy. This change causes state incompatibility — jobs using these functions require a stateless restart. To keep the previous behavior, set table.exec.legacy-stddev-behaviour to true. Affected functions: STDDEV_POP, STDDEV_SAMP, VAR_POP, VAR_SAMP.

Function Description
COUNT(\[ALL\] expression | DISTINCT expression1 \[, expression2\]\*) Returns the number of non-NULL input rows for expression (ALL by default).
COUNT(\*) | COUNT(1) Returns the total number of input rows.
AVG(\[ALL | DISTINCT\] expression) Returns the average of expression across all input rows (ALL by default).
SUM(\[ALL | DISTINCT\] expression) Returns the sum of expression across all input rows (ALL by default).
MAX(\[ALL | DISTINCT\] expression) Returns the maximum value of expression across all input rows (ALL by default).
MIN(\[ALL | DISTINCT\] expression) Returns the minimum value of expression across all input rows (ALL by default).
STDDEV_POP(\[ALL | DISTINCT\] expression) Returns the population standard deviation of expression (ALL by default).
STDDEV_SAMP(\[ALL | DISTINCT\] expression) Returns the sample standard deviation of expression (ALL by default).
VAR_POP(\[ALL | DISTINCT\] expression) Returns the population variance of expression (ALL by default).
VAR_SAMP(\[ALL | DISTINCT\] expression) Returns the sample variance of expression (ALL by default).
COLLECT(\[ALL | DISTINCT\] expression) Collects expression values across all input rows into a multiset (ALL by default).
VARIANCE(\[ALL | DISTINCT\] expression) Equivalent to VAR_SAMP().
RANK() Returns the rank of a value within a group of values.
DENSE_RANK() Returns the dense rank of a value, incrementing by 1 for each distinct value.
ROW_NUMBER() Returns the sequential row number within a window partition, starting from 1.
LEAD(expression \[, offset\] \[, default\]) Returns the expression value from the row offset positions after the current row. Not supported in streaming mode.
LAG(expression \[, offset\] \[, default\]) Returns the expression value from the row offset positions before the current row.
LISTAGG(expression \[, separator\]) Concatenates string expression values, separated by separator.
APPROX_COUNT_DISTINCT Returns an approximate count of distinct values. Use instead of COUNT(DISTINCT) to improve job performance.
FIRST_VALUE Returns the first non-NULL record in a data stream.
LAST_VALUE Returns the last non-NULL record in a data stream.