snowflake.snowpark.functions.sql_expr

snowflake.snowpark.functions.sql_expr(sql: str, *, is_constant: bool = False) Column[source]

Creates a Column expression from raw SQL text. Note that the function does not interpret or check the SQL text.

Parameters:
  • sql – The raw SQL text to embed as a column expression.

  • is_constant – When True, indicates that sql is a constant value (for example an object/array/scalar literal) that does not reference any input columns. This allows the SQL simplifier to treat the expression as having no column dependencies.

Example::
>>> df = session.create_dataframe([[1, 2], [3, 4]], schema=["A", "B"])
>>> df.select(sql_expr("a + 1").as_("c"), sql_expr("a = 1").as_("d")).collect()  # use SQL expression
[Row(C=2, D=True), Row(C=4, D=False)]