snowflake.snowpark.functions.lit¶
- snowflake.snowpark.functions.lit(literal: LiteralType) Column [source]¶
Creates a
Column
expression for a literal value. It supports basic Python data types, includingint
,float
,str
,bool
,bytes
,bytearray
,datetime.time
,datetime.date
,datetime.datetime
anddecimal.Decimal
. Also, it supports Python structured data types, includinglist
,tuple
anddict
, 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 |} | | | | | | | |] | | ---------------------------------------------------------------------------------------