This topic describes the built-in functions available for expressions in the transform module of Flink CDC data ingestion jobs.
Built-in functions
Flink CDC data ingestion jobs offer a rich set of built-in functions for use in projection and filter expressions within the transform module.
Arithmetic functions
Function | Description |
numeric1 + numeric2 | Returns the sum of |
numeric1 - numeric2 | Returns the result of subtracting |
numeric1 * numeric2 | Returns the product of |
numeric1 / numeric2 | Returns the result of dividing |
numeric1 % numeric2 | Returns the remainder of dividing |
ABS(numeric) | Returns the absolute value of |
CEIL(numeric) | Rounds |
FLOOR(numeric) | Rounds |
ROUND(numeric, int) | Rounds |
UUID() | Generates a Universally Unique Identifier (UUID) as a string (for example, "3d3c68f7-f608-473f-b60c-b0c44ad4cc4e"). The UUID is generated using the RFC 4122 type 4 pseudo-random method. |
Time functions
Function | Description |
LOCALTIME | Returns the local time in the current time zone. The return type is |
LOCALTIMESTAMP | Returns the local timestamp in the current time zone. The return type is |
CURRENT_TIME | An alias for |
CURRENT_DATE | Returns the local date in the current time zone. |
CURRENT_TIMESTAMP | Returns the local timestamp in the current time zone. The return type is |
NOW() | An alias for |
DATE_FORMAT(timestamp, string) | Formats the input timestamp according to the specified format string. Note The format string is compatible with Java's |
TIMESTAMPADD(timeintervalunit, interval, timepoint) | Adds a specified time The |
TIMESTAMPDIFF(timepointunit, timepoint1, timepoint2) | Calculates the difference between The |
TO_DATE(string1[, string2]) | Converts the date string Note If the format string |
TO_TIMESTAMP(string1[, string2]) | Converts the timestamp string Note If the format string |
FROM_UNIXTIME(numeric[, string]) | Converts the first argument, which represents the number of seconds elapsed since 1970-01-01 00:00:00 UTC, into a formatted timestamp string, using the format specified in the second argument. Note If the format string is not specified, the default format 'yyyy-MM-dd HH:mm:ss' is used. |
UNIX_TIMESTAMP() | Returns the current UNIX timestamp in seconds. |
UNIX_TIMESTAMP(string1[, string2]) | Converts the date-time string |
All sub-expressions calling time functions within projection and filter expressions will share the same time value. For example, in NOW() AS t1, NOW() AS t2, NOW() AS t3, the values of t1, t2, and t3 will be identical, regardless of the evaluation time or order.
String functions
Function | Description |
string1 || string2 | Concatenates Note This operator is different from the logical OR operator. |
CHAR_LENGTH(string) | Returns the number of characters in |
UPPER(string) | Returns the uppercase version of |
LOWER(string) | Returns the lowercase version of |
TRIM(string1) | Removes leading and trailing whitespace characters from |
REGEXP_REPLACE(string1, string2, string3) | Replaces all substrings in For example, |
SUBSTRING(string FROM integer1 [ FOR integer2 ]) | Returns a substring of Note If the |
CONCAT(string1, string2,…) | Concatenates two or more strings. For example, |
Type casting functions
Use the CAST(<expression> AS <type>) syntax for explicit type casting. The following conversions are currently supported:
Source type | Target type | Description |
Any |
Important You cannot currently use | Converts any data type to a string. |
|
| Converts any non-zero numeric literal or a string literal other than 'FALSE' to TRUE. |
|
| Truncates the result to fit within the range of -128 to 127. |
|
| Truncates the result to fit within the range of -32768 to 32767. |
|
| Truncates the result to fit within the range of -2147483648 to 2147483647. |
|
| Truncates the result to fit within the range of -9223372036854775808 to 9223372036854775807. |
|
| |
|
| |
|
| |
|
| The string must be in a valid ISO_LOCAL_DATE_TIME format. |
Comparison functions
If any input parameter is NULL, these functions return NULL unless specified otherwise.
Function | Description |
| Returns TRUE if |
value1 <> value2 | Returns TRUE if |
value1 > value2 | Returns TRUE if |
value1 >= value2 | Returns TRUE if |
value1 < value2 | Returns TRUE if |
value1 <= value2 | Returns TRUE if |
value IS NULL | Returns TRUE if |
value IS NOT NULL | Returns TRUE if |
value1 BETWEEN value2 AND value3 | Returns TRUE if |
value1 NOT BETWEEN value2 AND value3 | Returns TRUE if |
string1 LIKE string2 | Returns TRUE if |
string1 NOT LIKE string2 | Returns TRUE if |
value1 IN (value2 [, value3]* ) | Returns TRUE if |
value1 NOT IN (value2 [, value3]* ) | Returns TRUE if |
Logical functions
Function | Description |
| Returns TRUE if at least one of |
| Returns TRUE if both |
NOT boolean | Inverts the boolean value. |
boolean IS FALSE | Returns TRUE if |
boolean IS NOT FALSE | Returns TRUE if |
boolean IS TRUE | Returns TRUE if |
boolean IS NOT TRUE | Returns TRUE if |
Conditional functions
Function | Description |
CASE value WHEN value1_1 [, value1_2]* THEN RESULT1 (WHEN value2_1 [, value2_2 ]* THEN result_2)* (ELSE result_z) END | Sequentially checks if If no clause's condition is met, it returns the value specified in the ELSE clause. If no ELSE clause is specified, it returns NULL. |
CASE WHEN condition1 THEN result1 (WHEN condition2 THEN result2)* (ELSE result_z) END | Sequentially evaluates the condition in each WHEN clause and returns the If no clause's condition is met, it returns the value specified in the ELSE clause. If no ELSE clause is specified, it returns NULL. |
COALESCE(value1 [, value2]*) | Returns the first non-NULL value in the list |
IF(condition, true_value, false_value) | If the |