snowflake.snowpark.functions.lit

snowflake.snowpark.functions.lit(literal: Union[None, bool, int, float, str, bytearray, Decimal, date, datetime, time, bytes, list, tuple, dict]) Column[source]

Creates a Column expression for a literal value. It supports basic Python data types, including int, float, str, bool, bytes, bytearray, datetime.time, datetime.date, datetime.datetime and decimal.Decimal. Also, it supports Python structured data types, including list, tuple and dict, but this container must be JSON serializable.

Example:

>>> import datetime
>>> columns = [lit(1), lit("1"), lit(1.0), lit(True), lit(b'snow'), lit(datetime.date(2023, 2, 2)), lit([1, 2]), lit({"snow": "flake"})]
>>> session.create_dataframe([[]]).select([c.as_(str(i)) for i, c in enumerate(columns)]).show()
---------------------------------------------------------------------------------------
|"0"  |"1"  |"2"  |"3"   |"4"                 |"5"         |"6"   |"7"                |
---------------------------------------------------------------------------------------
|1    |1    |1.0  |True  |bytearray(b'snow')  |2023-02-02  |[     |{                  |
|     |     |     |      |                    |            |  1,  |  "snow": "flake"  |
|     |     |     |      |                    |            |  2   |}                  |
|     |     |     |      |                    |            |]     |                   |
---------------------------------------------------------------------------------------
Copy