This topic describes all built-in functions that are supported by Realtime Compute for Apache Flink.
Supported functions
For Realtime Compute for Apache Flink that uses Ververica Runtime (VVR) 3.0.0, some built-in functions are supported based on Flink V1.12. For more information, see Scalar functions, Table-valued functions, and Aggregate functions. The following tables describe all built-in functions supported by Realtime Compute for Apache Flink based on Flink V1.15.
The supported functions may vary based on the Flink version. For more information about the built-in functions supported by Realtime Compute for Apache Flink, see Flink V1.12 built-in functions, Flink V1.13 built-in functions, Flink V1.14 built-in functions, Flink V1.15 built-in functions, Flink V1.16 built-in functions, and Flink V1.17 built-in functions.
If the functions that you require are not built in Realtime Compute for Apache Flink, you can use user-defined functions (UDFs). For more information about UDFs, see Overview.
Scalar functions
Category | Function | Description |
Comparison functions | Returns true if value1 is equal to value2. | |
Returns true if value1 is not equal to value2. | ||
Returns true if value1 is greater than value2. | ||
Returns true if value1 is greater than or equal to value2. | ||
Returns true if value1 is less than value2. | ||
Returns true if value1 is less than or equal to value2. | ||
Returns true if the value is NULL. | ||
Returns true if the value is not NULL. | ||
Returns true if the data types or values of value1 and value2 are different. All NULL values are considered equal. | ||
Returns true if the data types and values of value1 and value2 are the same. All NULL values are considered equal. | ||
Returns true by default or when the ASYMMETRIC keyword is used if the following condition is met: value1 is greater than or equal to value2 and less than or equal to value3. | ||
value1 NOT BETWEEN [ ASYMMETRIC | SYMMETRIC ] value2 AND value3 | Returns true by default or when the ASYMMETRIC keyword is used if the following condition is met: value1 is less than value2 or greater than value3. | |
Returns true if string1 matches string2. | ||
Returns true if string1 does not match string2. | ||
Returns true if string1 matches the SQL regular expression string2. | ||
Returns true if string1 does not match the SQL regular expression string2. | ||
Returns true if value1 exists in the list of values (value2, value3, …). | ||
Returns true if value1 does not exist in the list of values (value2, value3, …). | ||
Returns true if at least one row of data is returned for the subquery. | ||
Returns true if the value is equal to one row of data in the subquery result set. | ||
Returns true if the value is not included in the rows of data returned by the subquery. | ||
Logical functions | Performs a bitwise AND operation. | |
Performs a bitwise NOT operation. | ||
Performs a bitwise OR operation. | ||
Performs a bitwise XOR operation. | ||
Returns true if boolean1 or boolean2 is true. | ||
Returns true if boolean1 and boolean2 are true. | ||
Returns true if boolean is false. Returns false if boolean is true. Returns unknown if boolean is unknown. | ||
Returns true if boolean is false. Returns false if boolean is true or unknown. | ||
Returns true if boolean is true or unknown. Returns false if boolean is false. | ||
Returns true if boolean is true. Returns false if boolean is false or unknown. | ||
Returns true if boolean is false or unknown. Returns false if boolean is true. | ||
Returns true if boolean is unknown. Returns false if boolean is true or false. | ||
Returns true if boolean is true or false. Returns false if boolean is unknown. | ||
Arithmetic functions | Returns a numeric value. | |
Returns a value that is opposite the numeric value. | ||
Returns the sum of numeric1 and numeric2. | ||
Returns the difference of numeric1 and numeric2. | ||
Returns the product of numeric1 multiplied by numeric2. | ||
Returns the quotient of numeric1 divided by numeric2. | ||
Returns the remainder of numeric1 divided by numeric2. | ||
Returns the value of numeric1 to the power of numeric2. | ||
Returns the absolute value of the numeric value. | ||
Returns the square root of the numeric value. | ||
Returns the natural logarithm of the numeric value with the base number of e. | ||
Returns the natural logarithm of the numeric value with the base number of 10. | ||
Returns the natural logarithm of the numeric value with the base number of 2. | ||
Returns the natural logarithm of numeric2 if one input parameter is called. Returns the natural logarithm of numeric2 with the base number of numeric1 if two input parameters are called. The value of numeric2 must be greater than 0 and the value of numeric1 must be greater than 1. | ||
Returns the result of e raised to the power of numeric. | ||
Rounds up a number and returns the smallest integer that is greater than or equal to numeric. | ||
Rounds down a number and returns the largest integer that is less than or equal to numeric. | ||
Returns the sine of the numeric value. | ||
Returns the hyperbolic sine of the numeric value. The return value is of the DOUBLE data type. | ||
Returns the cosine of the numeric value. | ||
Returns the tangent value of the numeric value. | ||
Returns the hyperbolic tangent value of the numeric value. The return value is of the DOUBLE data type. | ||
Returns the cotangent of the numeric value. | ||
Returns the arcsine of the numeric value. | ||
Returns the arccosine of the numeric value. | ||
Returns the arctangent of the numeric value. | ||
Returns the arctangent of the coordinate (numeric1, numeric2). | ||
Returns the hyperbolic cosine of the numeric value. The return value is of the DOUBLE data type. | ||
Returns the degree of the radian numeric. | ||
Returns the radian of the degree numeric. | ||
Returns the sign of the numeric value. | ||
Returns a value rounded to INT decimal places for the numeric value. | ||
Returns a value that is extremely close to pi. | ||
Returns a value that is extremely close to e. | ||
Returns a pseudorandom double-precision value in the range of [0.0, 1.0). | ||
Returns a pseudorandom double-precision value in the range of [0.0, 1.0) with an initial seed of INT. | ||
Returns a pseudorandom integer in the range of [0, INT). | ||
Returns a pseudorandom integer in the range of [0, INT2) with an initial seed of INT1. | ||
Returns a Universally Unique Identifier (UUID) string based on RFC 4122 Type 4. The UUID string is pseudo randomly generated. | ||
Returns a string of the INTEGER data type in the binary format. | ||
Returns an integer NUMERIC value or a string in the hexadecimal format. | ||
Returns a number that is truncated to the number of decimal places that are specified by integer2. | ||
String functions | Returns the concatenation of string1 and string2. | |
Returns the number of characters in a string. | ||
Returns a string in uppercase letters. | ||
Returns a string in lowercase letters. | ||
Returns the position of the first occurrence of string1 in string2. The position starts from 1. Returns 0 if string1 does not exist in string2. | ||
Removes a string that begins, ends, or begins and ends with string1 from string2 and returns the result. This function removes all characters at the end of the string until a character that is not in the TRAILING parameter exists. For example, TRIM(TRAILING 'fe' from 'abcdef') returns abcd. | ||
Removes the spaces on the left side of a string. | ||
Removes the spaces on the right side of a string. | ||
Returns a string that repeats the specified string for the number of times that are specified by int. | ||
Replaces the specified string with the desired string and returns a new string. | ||
OVERLAY(string1 PLACING string2 FROM integer1 [ FOR integer2 ]) | Replaces a total number of integer2 characters in string1 with string2 from the position specified by integer1 and returns a new string. By default, integer2 indicates the length of string2. | |
Returns a substring that starts from the position specified by integer1 in a string and has a length specified by integer2. By default, integer2 specifies the length from the position integer1 to the end of the string. | ||
Replaces all occurrences of string2 with string3 in string1 and returns a new string. string2 and string3 are non-overlapping. | ||
Splits string1 based on the regular expression specified by string2 and returns the string at the specified position specified by integer. | ||
Converts a string into a string in the specified format. In this format, the first letter of each word is in uppercase, and the other letters of each word are in lowercase. Each word in the string represents a sequence of alphanumeric characters. | ||
Concatenates multiple strings and returns a new string. If an input parameter is set to NULL, NULL is returned. | ||
Returns a string that concatenates string2, string3, … with a separator specified by string1. | ||
Left pads string1 with string2 to the length specified by integer. | ||
Right pads string1 with string2 to the length specified by integer. | ||
Decodes string1 by using the Base64 algorithm. | ||
Encodes string1 by using the Base64 algorithm. | ||
Returns the ASCII code of the first character in a string. | ||
Returns the ASCII character that has the binary value equivalent to a value specified by integer. | ||
Decodes a string in the specified encoding format, such as US-ASCII, ISO-8859-1, UTF-8, UTF-16BE, UTF-16LE, or UTF-16. | ||
Encodes a string in the specified encoding format, such as US-ASCII, ISO-8859-1, UTF-8, UTF-16BE, UTF-16LE, or UTF-16. | ||
Returns the position of the first occurrence of string2 in string1. | ||
Returns the leftmost characters with a length of integer from a string. | ||
Returns the rightmost characters with a length of integer from a string. | ||
Returns the position of the first occurrence of string1 in string2 after the position specified by integer. | ||
Parses a specific part of a URL and returns the obtained value. | ||
Searches for the specified string by using a regular expression and returns a Boolean value based on the search result. | ||
Returns a string in reverse order. | ||
Splits a string into several segments based on the specified delimiter and returns the field at the specified position. | ||
Splits string1 into key-value pairs by using a delimiter and returns a map. | ||
Returns a substring that starts from the position specified by integer1 in a string. The substring has a length specified by integer2. | ||
Time functions | Returns a date value in SQL parsed from a string in the yyyy-MM-dd format. | |
Calculates the difference between two date values. | ||
Returns a date value that is a specified number of days later than a given date. | ||
Returns a date value that is a specified number of days earlier than a given date. | ||
Returns a time value in SQL parsed from a string in the HH:mm:ss format. | ||
Returns a timestamp in SQL parsed from a string in the yyyy-MM-dd HH:mm:ss[.SSS] format. | ||
Parses intervals in milliseconds in SQL from a string in the dd hh:mm:ss.fff format or parses intervals in months in SQL from a string in the yyyy-mm format. | ||
Returns the current time in SQL in the local time zone. The return value is of the TIME(0) type. | ||
Returns the current time in SQL in the local time zone. The return value is of the TIMESTAMP(3) type. | ||
Returns the current time in SQL in the local time zone. This function is equivalent to the LOCAL_TIME function. | ||
Returns the current date in SQL in the local time zone. | ||
Returns the current timestamp in SQL in the local time zone. | ||
Returns the current timestamp in SQL in the local time zone. This function is equivalent to the CURRENT_TIMESTAMP function. | ||
Returns the current timestamp in SQL in the local time zone. | ||
Returns a value of the LONG data type extracted from the timeintervalunit part of temporal. | ||
Returns the year in which a date value in SQL falls. | ||
Returns the quarter in which a date value in SQL falls. | ||
Returns the month in which a date value in SQL falls. | ||
Returns the sequence number of the week in the year in which a date value in SQL falls. | ||
Returns the sequence number of the day in the year in which a date value in SQL falls. | ||
Returns the sequence number of the day in the month in which a date value in SQL falls. | ||
Returns the hour component of a timestamp in SQL. | ||
Returns the minute component of a timestamp in SQL. | ||
Returns the second component of a timestamp in SQL. | ||
Returns a value that rounds a point in time down to the time unit that is specified by timeintervalunit. | ||
Returns a value that rounds a point in time up to the time unit that is specified by timeintervalunit. | ||
Returns true if the two time intervals defined by (timepoint1, temporal1) and (timepoint2, temporal2) overlap. | ||
Converts a date value of the STRING data type into the specified format. | ||
Converts data of the TIMESTAMP data type into a string of the specified format based on the specified time zone. | ||
Returns a new point in time by adding a period of time to a given point in time. The period of time is equivalent to timeintervalunit multiplied by interval. | ||
Returns the time interval between timepoint1 and timepoint2. | ||
Converts a datetime string1 from the time zone string2 into the value of the time zone string3. The datetime string1 is in the default ISO timestamp format yyyy-MM-dd HH:mm:ss. | ||
Returns a date value of the VARCHAR data type. | ||
Converts a date value into a UNIX timestamp. | ||
Converts a date value of the INT or VARCHAR data type to the DATE data type. | ||
Converts a time to a value of the TIMESTAMP_LTZ data type. The time is a UNIX timestamp. Unit: milliseconds or seconds. | ||
Converts string1 in the format of string2 in the UTC+0 time zone into a timestamp. By default, the format specified by string2 is yyyy-MM-dd HH:mm:ss. | ||
Converts a date value of the VARCHAR data type into the TIMESTAMP data type based on the specified time zone. | ||
Returns the current watermark for the given time column property specified by rowtime. | ||
Conditional functions | Returns resultX if the first time value is included in a list of values (valueX_1, valueX_2, …). | |
CASE WHEN condition1 THEN result1 (WHEN condition2 THEN result2)* (ELSE result_z) END | Returns resultX when the first condition X is met. | |
Returns NULL if value1 is equal to value2. Returns value1 if value1 is not equal to value2. | ||
Returns the first non-NULL value from value1, value2, …. | ||
Returns true_value if the condition is met. Returns false_value if the condition is not met. | ||
Returns null_replacement if the input parameter is NULL. Returns the input parameter if the input parameter is not NULL. | ||
Returns true if all characters in a string are letters. Returns false if any characters in a string are not letters. | ||
Returns true if a string can be parsed to a valid number. Returns false if a string cannot be parsed to a valid number. | ||
Returns true if all characters in a string are digits. Returns false if any characters in a string are not digits. | ||
Returns the maximum value of the input parameters. Returns NULL if an input parameter is set to NULL. | ||
Returns the minimum value of the input parameters. Returns NULL if an input parameter is set to NULL. | ||
Data type conversion functions | Performs base conversation on numeric values or characters. | |
Returns a new value that is converted into type. | ||
Returns the string representation of the data type of the input expression. | ||
Collection functions | Returns the number of elements in an array. | |
Returns the element at the position specified by INT in an array. | ||
Returns the only element of an array whose cardinality is 1. | ||
Returns the number of entries in a map. | ||
Returns the value that corresponds to the specified key in a map. | ||
JSON functions | Determines whether a given string is a valid JSON string. | |
JSON_EXISTS(jsonValue, path [ { TRUE | FALSE | UNKNOWN | ERROR } ON ERROR ]) | Determines whether a JSON string meets the given path search criteria. | |
Serializes a value into a JSON string that contains the serialized value. | ||
Extracts the expression of the specified path from a JSON string. | ||
Extracts a JSON value from a JSON string. | ||
JSON_OBJECT([[KEY] key VALUE value]* [ { NULL | ABSENT } ON NULL ]) | Generates a JSON object from a list of key-value pairs. | |
JSON_OBJECTAGG([KEY] key VALUE value [ { NULL | ABSENT } ON NULL ]) | Aggregates key-value expressions into a JSON object. | |
Generates a JSON array from a list of values. | ||
Generates a JSON object by aggregating items into an array. | ||
Value construction functions | -- implicit constructor with parenthesis (value1 [, value2]*) | Returns a row of data created from a list of values (value1, value2, …). |
Returns an array created from a list of values (value1, value2, …). | ||
Returns a map created from a list of key-value pairs ((value1, value2), (value3, value4), …). | ||
Value acquisition functions | Extracts the value of a field of a composite data type of Flink, such as Tuple or POJO, by name. | |
Converts the subtypes of a composite data type of Flink, such as Tuple or POJO, into a separate field. | ||
Grouping functions | Returns an integer that uniquely identifies a combination of grouping keys. | |
GROUPING(expression1 [, expression2]* ) | GROUPING_ID(expression1 [, expression2]* ) | Returns a bit vector of the given grouping expressions. | |
Hash functions | Returns the MD5 hash value of a string in the format of a string of 32 hexadecimal digits. | |
Returns the SHA-1 hash value of a string in the format of a string of 40 hexadecimal digits. | ||
Returns the SHA-224 hash value of a string in the format of a string of 56 hexadecimal digits. | ||
Returns the SHA-256 hash value of a string in the format of a string of 64 hexadecimal digits. | ||
Returns the SHA-384 hash value of a string in the format of a string of 96 hexadecimal digits. | ||
Returns the SHA-512 hash value of a string in the format of a string of 128 hexadecimal digits. | ||
Returns a hash value by using a hash function, such as SHA-224, SHA-256, SHA-384, or SHA-512. | ||
Specifies the 32-bit hash value for a parameter by using the hash32x86 method. | ||
Specifies the 64-bit hash value for a parameter by using the hash128x64 method. | ||
Other functions | Checks whether the specified floating-point number is NAN (Not a number). This function is similar to the Double.isNan() or Float.isNan() function in Java. | |
Splits a string into key-value pairs based on the delimiter specified by split1, splits the key-value pairs based on the delimiter specified by split2, and returns the value that corresponds to the key. |
Table-valued functions
Function | Description |
Generates a series of padding data based on the rule of from, from+1, from+2 ... to-1. | |
Retrieves the values that are represented by each path string from a JSON string. | |
Splits a string into key-value pairs based on the key-value pair delimiter specified by split1, splits a key-value pair based on the delimiter specified by split2, and returns the values of key_name1 and key_name2. | |
Splits a string into substrings based on the specified delimiter and returns a list of substrings. |
Aggregate functions
Function | Description |
COUNT([ ALL ] expression | DISTINCT expression1 [, expression2]*) | Returns the number of input rows for an expression that is not NULL by default or if the ALL keyword is used. |
Returns the number of input rows. | |
Calculates the average value of the expressions in all input rows by default or if the ALL keyword is used. | |
Returns the sum of the expressions in all input rows by default or if the ALL keyword is used. | |
Returns the maximum value of the expressions in all input rows by default or if the ALL keyword is used. | |
Returns the minimum value of the expressions in all input rows by default or if the ALL keyword is used. | |
Returns the population standard deviation of the expressions in all input rows by default or if the ALL keyword is used. | |
Returns the standard deviation of samples of the expressions in all input rows by default or if the ALL keyword is used. | |
Returns the standard deviation of samples of the expressions in all input rows by default or if the ALL keyword is used. | |
Returns the sample variance of the expressions in all input rows by default or if the ALL keyword is used. | |
Returns multiple expressions across all input rows by default or if the ALL keyword is used. | |
This function is equivalent to the VAR_SAMP() function. | |
Returns the rank of a value in a group of values. | |
Returns the rank of a value in a group of values. The result is the sum of 1 and the previously assigned rank value. | |
Calculates the sequence number of a row based on the sequence of rows in a window partition. The row number starts from 1. | |
Returns the expression value at the offset row of data that follows the current row in a window. Note The LEAD function is not supported when a deployment is in streaming mode. | |
Returns the expression value at the offset row of data that precedes the current row in the window. | |
Concatenates the values of a string expression and separates the values with a delimiter. | |
Improves the performance of your deployments. | |
Returns the first non-NULL record of a data stream. | |
Returns the last non-NULL record of a data stream. |