Print

Scalar Functions

Scalar functions are calculated for one single value.

Scalar functions can be used in WINDOW conditions, WINDOW from expressions, QUERY SELECT, and QUERY conditions.

The following aggregate functions are available:

Functions Returning Boolean

FunctionDescription
matchesmatches( string, ‘regex pattern’) Slower performance!

Functions Returning Number

FunctionDescription
ceilceil(number) returns the number rounded up. ceil(3.4) returns 4.
datedate(string) converts string to epoc millis using the default date format in riodb.conf. date(string, format) returns epoch millis based on a given format. Example: date(‘03-aug-2003’,’dd-mon-yyyy’), as defined in SimpleDateFormat
date_adddate_add(my_timestamp, 5) adds 5 days to my_timestamp
date_addhoursdate_addhours(my_timestamp, 5) adds 5 hours to my_timestamp
date_addmillisdate_addmillis(my_timestamp, 5) adds 5 milliseconds to my_timestamp
date_addmimutesdate_addmimutes(my_timestamp, 5) adds 5 minutes to my_timestamp
date_addsecondsdate_addseconds(my_timestamp, 5050) adds 5 seconds to my_timestamp
decode_numberdecode(http_response,200,1,400,1,0) SQL decode function. But for numbers.
floorfloor (number) returns the number rounded down. floor(3.4) returns 3.
greatestgreatest(number1, number2, …, number_n) returns the greatest number passed.
ifnull_numberifnull(mynumber, 0) returns 0 if mynumber was null
instrinstr(string, substring) returns the position of the substring in string. -1 if not found.
leastleast(number1, number2, …, number_n) returns the lowest number passed.
lengthlength(string) returns the number of characters in a string
roundround(number) rounds a number half-up. round(3.4) is 3. round(3.5) is 4.
sysdatesysdate() returns the current date/time in epoch millis
to_numberto_number(string) converts the string representation of a number into a number datatype

Functions Returning String

FunctionDescription
concatconcat(string1, string2, …, string_n) returns a string made of concatenating the values passed.
decodedecode(my_string_field, ‘error’, ‘E’, ‘warning’, ‘W’, ‘info’, ‘I’, ‘O’). decode.
formatformat(timestamp) converts numeric epoch millis into human-readable date string.
ifnullifnull(myfield, ‘nothing’) replaces a value with another when null.
lowerlower(‘HELLO’) returns ‘hello’
replacereplace(‘HELLO’,’ELLO’,’APPY’) returns ‘HAPPY’
substrsubstr(‘BIG HOUSE’, 4) returns ‘HOUSE’
to_stringto_string(123.4) returns string datatype ‘123.4’
upperupper(‘hello’) return ‘HELLO’

Example

May be used in any expression, including mathematical evaluations, or grouping with parenthesis () .

SELECT upper(symbol), concat(symbol,'-NYSE'), replace(ifnull(lower(symbol),'nada'),'k','c')
WHEN greatest(s.avg,s.median) * to_number(tax_rate) < 100
CREATE WINDOW last_1000_bids
RUNNING count, sum, avg
FROM NUMBER (floor(my_stock_stream.bid))
WHEN greatest(s.avg,s.median) * to_number(tax_rate) < 100
Table of Contents
Scroll to Top