SQL Expressions
Jump to navigation
Jump to search
SQL expressions are special expressions in the expression language, which are converted into SQL and evaluated in an external system that supports SQL (e.g., Snowflake, SQL Server, Databricks, Redshift). Only a subset of expression language functionalities are supported by SQL expressions (which are explained in this page).
- Arithmetics operators: Addition (+), Subtraction (-), Multiplication (*), Division (/), Remainder (%)
- Comparison operators: ==, <, <=, >, >=, !=.
- Logical operators: && (AND), || (OR), ! (NOT) are used to combine expressions that return boolean values.
- Data types: strings ("this is a string"), integers (123), decimal numbers (123.45), booleans (true, false)
Function | Parameters | Description |
---|---|---|
CaseWhen | Number |
Goes through conditions and returns a value when the first condition is met, similar to an if-then-else. Once a condition is true, it will stop reading and return the result. If no conditions are true, it returns the value in the else-expression. Consists of any number of pairs of condition and value expressions followed by an optional else expression. CaseWhen(Column("a") == null, 1, Column("a") < 1.0, 2, 3) Returns 1 if the value of column "a" is null. Returns 2 if the value of column "a" is less than 1.0. Returns 3 otherwise. |