snowflake.snowpark.functions.hash¶
- snowflake.snowpark.functions.hash(*cols: Union[Column, str]) Column [source]¶
Returns a signed 64-bit hash value. Note that HASH never returns NULL, even for NULL inputs.
Examples:
>>> import decimal >>> df = session.create_dataframe([[10, "10", decimal.Decimal(10), 10.0]], schema=["a", "b", "c", "d"]) >>> df.select(hash("a").alias("hash_a"), hash("b").alias("hash_b"), hash("c").alias("hash_c"), hash("d").alias("hash_d")).collect() [Row(HASH_A=1599627706822963068, HASH_B=3622494980440108984, HASH_C=1599627706822963068, HASH_D=1599627706822963068)] >>> df.select(hash(lit(None)).alias("one"), hash(lit(None), lit(None)).alias("two"), hash(lit(None), lit(None), lit(None)).alias("three")).collect() [Row(ONE=8817975702393619368, TWO=953963258351104160, THREE=2941948363845684412)]