You are viewing documentation about an older version (1.3.0). View latest version

snowflake.snowpark.functions.iff

snowflake.snowpark.functions.iff(condition: ColumnOrSqlExpr, expr1: ColumnOrLiteral, expr2: ColumnOrLiteral) Column[source]

Returns one of two specified expressions, depending on a condition. This is equivalent to an if-then-else expression.

Parameters:
  • condition – A Column expression or SQL text representing the specified condition.

  • expr1 – A Column expression or a literal value, which will be returned if condition is true.

  • expr2 – A Column expression or a literal value, which will be returned if condition is false.

Examples:

>>> df = session.create_dataframe([True, False, None], schema=["a"])
>>> df.select(iff(df["a"], lit("true"), lit("false")).alias("iff")).collect()
[Row(IFF='true'), Row(IFF='false'), Row(IFF='false')]
Copy