Data Types and Operators¶
OPAL consists of a strongly typed language, with basic and advanced data types. The sections below describe these types, available operators for constructing expressions, and additional syntax details such as comments.
The verb and function references describe the types accepted by each verb or function, required or optional arguments, and if the verb accepts multiple arguments. The usage notation generally follows the notational convention for functions used in the Snowflake documentation.
Passing an argument of an unexpected type generates an error, so be sure to convert values when necessary.
Basic Data Types¶
Basic type |
Examples |
Related functions and expressions |
---|---|---|
bool |
|
Any expression that returns a boolean can be used to create one, even if it is not a string or integer. Example: |
duration |
|
Verbs and functions accept string durations using For other uses, the Duration values may be added or subtracted, and the result of adding or subtracting two timestamp values is a duration. |
float64 |
|
|
int64 |
|
|
string |
“abcde” |
You may escape Examples:
|
timestamp |
|
The Timestamps are stored internally in nanoseconds, so conversions to other types are based on nanosecond time. Timestamps are displayed in the UI as |
Advanced Data Types¶
Composite type |
Examples |
Related functions and expressions |
---|---|---|
variant |
A special-purpose type to aid type safety |
Used primarily with verbs and functions operating on JSON data. Corresponds to the Snowflake |
array |
A special data type used to list other data |
Arrays are composed of zero or more Variants in a list, meaning that an array can contain any mix of other data types. Corresponds to the Snowflake |
ipv4 |
|
|
object |
|
|
tdigest_agg |
|
|
options |
|
|
Regex literal |
|
For verbs and functions that accept a regular expression, a pattern to match delimited by |
Most types have a corresponding type_null()
function that creates a null value. To pass null
as an argument, use the appropriate function to create a value with the correct type. Example: make_col foo:string_null()
.
Operators¶
OPAL supports many common operators, as well as several additional ones for searching and accessing data within fields. Some have equivalent functions or alternate forms, which may be used interchangeably.
Arithmetic¶
Operator |
Operation |
---|---|
|
addition |
|
subtraction |
|
multiplication |
|
division |
|
group, for precedence |
Note
The output of dividing by zero is null
. The OPAL parser does not return an error or NaN, but instead returns null
for the expression. This is so an unexpected divide by zero doesn’t cause the entire pipeline to fail.
Comparison¶
Operator |
Equivalent Function |
Operation |
---|---|---|
|
|
equals |
|
|
not equal to |
|
|
less than |
|
|
greater than |
|
|
less than or equal to |
|
|
greater than or equal to |
Logical¶
Operator |
Operation |
---|---|
|
logical AND |
|
logical OR |
|
logical NOT |
Other¶
Operator |
Operation |
---|---|
|
nested field access for JSON |
|
subscript for element in an array or JSON |
|
name a field or value: |
|
search within the specified field or expression. Applies |
|
can be used to negate the match. |
|
search for the specified literal text |
See Examples for more on using these operators.