SQL Functions and Operators
Hazelcast supports logical and `IS` predicates, comparison and mathematical operators, and aggregate, mathematical, trigonometric, string, table-valued, and special functions.
Operators
Operators are used to evaluate and/or compare one or more operands. For example, in the expression (a + b), the + operator evaluates the addition of the a and b operands.
AND/OR
a |
b |
a AND b |
a OR b |
---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IS
Predicate | Description | Syntax |
---|---|---|
|
Evaluates to |
|
|
Evaluates to |
|
|
Evaluates to |
|
|
Evaluates to |
|
|
Evaluates to |
|
|
Evaluates to |
|
IN
At the moment, the SQL service does not support subqueries in IN clauses. For example, you cannot do SELECT column_names FROM table_name
WHERE column_name IN (SELECT STATEMENT);
|
Predicate | Description | Syntax |
---|---|---|
|
Evaluates to |
|
|
Evaluates to |
`SELECT column_names FROM table_name WHERE column_name NOT IN (value1, value2); |
BETWEEN
Predicate | Description | Syntax |
---|---|---|
|
Evaluates to |
|
|
Evaluates to |
|
|
Evaluates to |
|
|
Evaluates to |
|
CASE
Predicate | Description | Syntax |
---|---|---|
|
Returns a value when the first condition is met (like an if-then-else statement). |
|
Functions
Functions can either take operands as arguments and perform calculations on them or they can take no arguments and simply perform an independant calculation. For example, the function ABS(number)
takes a number and returns its absolute value.
Aggregate Functions
Aggregate functions perform calculations such as returning the mean of all data in a particular row.
You cannot aggregate data that comes a streaming query. |
For examples of how to use aggregate functions, see the SELECT
statement documentation.
For information about the input and return data types, see Data Types.
Function :: Returns | Description |
---|---|
|
Calculates the number of input rows. |
|
Calculates the number of input rows in which the input value is not null. |
|
Calculates the number of input rows in which the input value is unique. |
|
Calculates the number of input rows in which the input value is unique and not null. |
|
Calculates the sum of the non-null input values. |
|
Calculates the sum of the unique, non-null input values. |
|
Calculates the mean of all the non-null input values. |
|
Calculates the mean of all the unique, non-null input values. |
|
Calculates the minimum of the non-null input values. Applicable also to |
|
Calculates the maximum of the non-null input values. Applicable also to |
Date and Time Functions
Function | Description | Example | Result |
---|---|---|---|
|
Extracts Supported elements: Supported date types: |
|
24 |
|
Converts |
|
1970-01-01T03:00:00.001+03:00 1970-01-01T03:00:00.002+03:00 1970-01-01T03:00:00.003+03:00 |
|
Converts |
|
1000 2000 3000 |
File Table Functions
To execute an ad-hoc query against data in files you can use one of the predefined table functions:
-
csv_file
-
json_flat_file
-
avro_file
-
parquet_file
Table functions will create a temporary mapping, valid for the duration of the statement. These functions accept the same options as those available for the file connector.
You can use positional arguments:
SELECT * FROM TABLE(
CSV_FILE('/path/to/directory', '*.csv', MAP['key', 'value'])
)
Or named arguments:
SELECT * FROM TABLE(
CSV_FILE(path => '/path/to/directory', options => MAP['key', 'value'])
)
Mathematical Functions
Function | Description | Example | Result |
---|---|---|---|
|
Absolute value of the argument |
|
|
|
Returns the cube root of the input |
|
|
|
Returns the nearest integer greater than or equal to argument |
|
|
|
Converts radians to degrees |
|
|
|
Exponential |
|
|
|
Returns the nearest integer less than or equal to argument |
|
|
|
Natural logarithm |
|
|
|
Base 10 logarithm |
|
|
|
Returns the remainder of x / y |
|
|
|
Returns x to the power of y |
|
|
|
Converts degrees to radians |
|
|
|
Random value in the range [0.0; 1.0) |
|
|
|
Random value in the range [0.0; 1.0) using the given seed |
|
|
|
Rounds to an integer |
|
|
|
Rounds to |
|
|
|
Returns -1, 0 or 1 for negative, zero or positive argument, respectively |
|
|
|
Squares the input |
|
|
|
Returns the square root of the input |
|
|
|
Truncates to an integer |
|
|
|
Truncates to |
|
|
Trigonometric Functions
Function | Description |
---|---|
|
Inverse cosine |
|
Inverse sine |
|
Inverse tangent |
|
Arc tangent |
|
Cosine |
|
Cotangent |
|
Sine |
|
Tangent |
String Functions
Function | Description | Example | Result |
---|---|---|---|
|
Concatenates two strings |
|
|
|
Returns the ASCII code of the first character of the argument |
|
|
|
Equivalent to |
||
|
Returns a string that consists of the arguments |
|
John-Doe |
|
Converts the first letter of each word to upper case, and the rest to lower case |
|
|
|
Length of the string |
|
|
|
Returns |
|
|
|
Returns |
|
|
|
Returns |
|
|
|
Converts the string to lower case |
|
|
|
Equivalent to |
||
|
Returns the position of the first occurrence of |
|
|
|
Replaces all occurrences of |
|
|
|
Equivalent to |
||
|
Extracts a substring starting with the given position |
|
|
|
Extracts a substring starting with the given position for the given length |
|
|
|
Removes |
|
|
|
Equivalent to |
|
|
|
Equivalent to |
|
|
|
Converts a string to upper case |
|
|
Table-Valued Functions
Table-valued functions return tables of batch or streaming sources that you can use in SQL statements.
Function | Description |
---|---|
|
Returns a table that contains a series of numbers, starting from the |
|
Returns a table that contains a stream of numbers, starting from 0 at a rate of |
Special Functions
Function | Description | Example |
---|---|---|
Converts the value to the given type. |
|
|
|
Returns |
|
|
Evaluates each expression at a time, starting from the first. If the value of any expression is not |
|