Functions¶
The table below contains the list of all supported LSQL functions.
Name  Description  Usage 

ANONYMIZE  Obfuscates the data, in order to protect it. If the anonymized
value is not provided it will use
* for String and 0 for Numbers 
anonymize(expression [,Anonymized value]) 
CAST 

cast(dt as int) 
COALESCE  Returns the first nonnull expression in the expression list.
You must specify two expressions

coalesce(value, prevValue) 
CONCATENATE  Returns the string representation of concatenating each
expression in the list. Null fields are left out

concatenate(weather.main, 'fixed', dt,temp.eve) 
LEN  Returns the length of a string. LEN calculates length
using characters as defined by UTF16

len(name) 
POSITION  Return the position of the first occurrence of substring  position('math' in fieldA) 
REPLACE  Returns string with every occurrence of
search_string replaced with
replacement_string 
replace(fieldA, 'math', 'mathematics') 
SUBSTRING  Return a portion of the string, beginning at the given position  substring(field, 2) 
TRIM  Removes leading and trailing spaces  trim(field) 
LOWER  Returns the argument in lowercase  lower(name) 
UPPER  Returns the argument in uppercase  upper(name) 
UUID  Returns an universally unique identifier  uuid() 
ABS  Returns the absolute value of an
expression it has to evaluate to a number type

abs(field1 + field2) 
CEIL  Returns the absolute value of an
expression it has to evaluate to a number type

ceil(field1) 
FLOOR  Return the largest value not greater than the argument  floor(field1) 
‘%’  The remainder operator (%) computes the remainder after
dividing its first operand by its second. Each expression has
to evaluate to a number

a % b 
‘/’  Divides one number by another (an arithmetic operator)
Each expression has to evaluate to a number

a / b 
‘‘  Subtracts one number from another (an arithmetic operator)
Each expression has to evaluate to a number

a  b 
‘*’  Multiplies one number from another (an arithmetic operator)
Each expression has to evaluate to a number

a * b 
‘+’  Adds one number to another (an arithmetic operator)
Each expression has to evaluate to a number

a + b 
‘‘ (negative)  Returns the negative of the value of a numeric expression
(a unary operator). The expression has to evaluate to a number

a * b 
POW  Returns expression1 raised to the expression2 power.
Each expression has to evaluate to a number

pow(a, b) 
SQRT  Returns the square root of expression.
The expression has to evaluate to a number

sqrt(a) 
COUNT  Returns the number of records read
ONLY FOR STREAMING when grouping is involved 
SELECT count(*) 
MAX  Returns maximum value of expression.
ONLY FOR STREAMING when grouping is involved 
max(field1) 
MIN  Returns minimum value of expression.
ONLY FOR STREAMING when grouping is involved 
min(field1) 
SUM  Returns the sum of expression for each record read.
ONLY FOR STREAMING when grouping is involved 
sum(field1) 
IF  Evaluates the boolean result for condition. If true it will
return the value of expr1; otherwise, it evaluates and
returns the value of expr2

if(condition, expr1,expr2) 
LPAD  Prepends the value of padExpr to the value of strExpr
until the total length is lengthExpr

LPAD(strExpr, lengthExpr, padExpr) 
RPAD  Appends the value of padExpr to the value of strExpr
until the total length is lengthExpr

LPAD(strExpr, lengthExpr, padExpr) 
EPOCH_TO_DATETIME  Converts an epoch into a datetime
yyyyMMdd'T'HH:mm:ss.SSSZ strExpr needs to be a LONG value containing the
milliseconds since 1 January 1970 00:00:00)

EPOCH_TO_DATETIME(strExpr) 
EPOCH_TO_DATE  Converts an epoch into a date
yyyyMMdd The strExpr needs to resolve to INT/LONG value. If the
value is an INT it is expected to be the day represented
as days since epoch

EPOCH_TO_DATE(strExpr) 
DATETIME_TO_EPOCH  Converts a string representation of a datetime into epoch value.
For AVRO records the new field will be of type Long with the
Timestamp logical type attached and the epoch value.
For JSON records the epoch will be expressed as LONG.
The first parameter strExpr needs to be a STRING value.
The second parameter pattern must be a DateTime Format

DATETIME_TO_EPOCH(strExpr, pattern) 
DATE_TO_EPOCH  Converts a string representation of a date into epoch value.
For AVRO records, this will emit a field with a logical type of
Date. This means the output value is an INT and it represents
the days since Epoch. For JSON records the resulted value is the
epoch expressed as LONG. The first parameter strExpr needs to
resolve to a STRING value. The second parameter pattern,
must be a Date Format

DATE_TO_EPOCH(strExpr, pattern) 
CONVERT_TIME  Converts the string format of a date [and time]. The first
parameter strExpr needs be a STRING value. The second
parameter fromPattern is the incoming date[and time] format.
The last parameter represents the target date[and time] format.

CONVERT_TIME(strExpr, fromPattern, toPattern) 
CURDATE
CURRENT_DATE

Provides the current date value. For JSON records the result
is a human readable date value represented as
yyyyMMdd .For AVRO records the resulting field will be of type INT and
will have the logical type DATE attached

CURDATE()/CURRENT_DATE() 
CURRENT_DATETIME
NOW
CURTIME

Provides the current date and time. For JSON records the
result is a human readable date and time value represented
as
yyyyMMdd'T'HH:mm:ss.SSSZ . For AVRO records the resultingfield will be of type LONG and will have the
the logical type TIMESTAMP attached

NOW()/CURTIME()/CURRENT_DATETIME() 
ARRAY_SIZE  Returns the count of elements contained by the parameter.
It is expected the parameter, evaluates to
an array structure.

ARRAY_SIZE(EXPR) 
REGEXP  Returns the matched groups otherwise null.
Consider this regular expression
(MrMrsMs) ([AZ][az]+) ([AZ][az]+) and this input
Ms Jane Smith ; the return values are:["Ms Jane Smith", "Ms", "Jane", "Smith"] . 
REGEXP(SQL_EXPR, REGEX_EXPR) 
REGEXP_LIKE  Returns true if the input value matches the expression
otherwise false.

REGEXP_LIKE(SQL_EXPR, REGEX_EXPR) 
REGEXP_REPLACE  Replace the matched text with the provided value.
If there’s no match the input will
remain the same.

REGEXP_REPLACE(SQL_EXPR, SQL_EXPR, REGEX_EXPR) 
EXISTS  Returns true if the given field is present; false otherwise
. 
EXISTS(FIELD_EXPR) 
HEADERASSTRING  Returns the value of the record header key as
a STRING value.

HEADERASSTRING('HEADER_KEY') 
HEADERASINT  Returns the value of the record header key as
an INT value.

HEADERASINT('HEADER_KEY') 
HEADERASLONG  Returns the value of the record header key as
a LONG value.

HEADERASLONG('HEADER_KEY') 
HEADERASDOUBLE  Returns the value of the record header key as
a DOUBLE value.

HEADERASDOUBLE('HEADER_KEY') 
HEADERASFLOAT  Returns the value of the record header key as
a FLOAT value.

HEADERASFLOAT('HEADER_KEY') 
HEADERKEYS  Returns all the header keys for the current
record.

HEADERKEYS() 
Anonymize your data¶
At times you might not want the data published to a topic to contain sensitive information.
Therefore when a SQL Processor is created you might need to anonymize some of the data.
The grammar supports such a construct via the ANONYMIZE
function.
SELECT anonymize(username)
, _key as card_number
, lastTransactionTimestamp
FROM credit_cards