IF_ELSE

If there is a 'true' boolean value in the 'condition' parameter then return the second argument. In all other cases, return the third argument

Syntax

IF_ELSE(condition, true_value, false_value)

Arguments

NameTypeDescriptionDefault Value

condition

boolean

If this is true, return the second argument, otherwise return the third argument.

true_value

any

The value to return when the condition is true

false_value

any

The value to return when the condition is not true

Examples

conditiontrue_valuefalse_valueOutput

true

'foo'

'bar'

foo

false

'foo'

'bar'

bar

null::boolean

'foo'

'bar'

bar

Transformation job example

SQL

CREATE JOB function_operator_example
    ADD_MISSING_COLUMNS = true
    AS INSERT INTO default_glue_catalog.upsolver_samples.orders_transformed_data MAP_COLUMNS_BY_NAME
    SELECT condition, true_value, false_value,
        IF_ELSE(condition, true_value, false_value) AS Output
    FROM default_glue_catalog.upsolver_samples.orders_raw_data
    LET condition = true,
        true_value = 'foo',
        false_value = 'bar'
    WHERE time_filter()
    LIMIT 1;

Query result

conditiontrue_valuefalse_valueOutput

true

'foo'

'bar'

foo

Last updated