Scalar Functions

The following are scalar functions for KSQL.

Table 1.
Function Example Description
ABS ABS(col1) Absolute value of a value.
CEIL CEIL(col1) Ceiling of a value.
CONCAT CONCAT(col1, '_hello') Concatenate two strings.
EXTRACTJSONFILELD EXTRACTJSONFIELD(message, '$') Given a sring column in JSON format, extract the field that matches.
ARRAYCONTAINS ARRAYCONTAINS('[1, 2, 3]', 3 Given a JSON or AVRO array, checks if a search value is contained in it.
FLOOR FLOOR(col1) Floor of a value.
LCASE LCASE(col1) Convert a string to lowercase.
LEN LEN(col1) Length of a string.
RANDOM RANDOM() Returns a random DOUBLE value between 0 and 1.0
ROUND ROUND(col1 Round a value to the nearest BIGINT value.
STRINGTOTIMESTAMP STRINGTOTIMESTAMP(col1, 'yyyy-MM-dd HH:mm:ss.SSS') Converts a string value in the given format into the BIGINT value representing the timestamp.
SUBSTRING SUBSTRING(col1, 2, 5) Returns the substring with the start and end indices.
TIMESTAMPTOSTRING TIMESTAMPTOSTRING(ROWTIME, 'yyyy-MM-dd HH:mm:ss.SSS') Converts a BIGINT timestamp value into the string representation of the timestamp in the given format.
TRIM TRIM(col1) Trim the spaces from the beginning and the end of the string.
CASE CASE(col1) Convert a string to uppercase.