snowflake.snowpark.functions.lit¶
- snowflake.snowpark.functions.lit(literal: Union[None, bool, int, float, str, bytearray, Decimal, date, datetime, time, bytes, NaTType, float64, list, tuple, dict]) Column[source] (https://github.com/snowflakedb/snowpark-python/blob/v1.23.0/src/snowflake/snowpark/functions.py#L292-L316)¶
- Creates a - Columnexpression for a literal value. It supports basic Python data types, including- int,- float,- str,- bool,- bytes,- bytearray,- datetime.time,- datetime.date,- datetime.datetimeand- decimal.Decimal. Also, it supports Python structured data types, including- list,- tupleand- 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 |} | | | | | | | |] | | ---------------------------------------------------------------------------------------