Nota:
El acceso a esta página requiere autorización. Puede intentar iniciar sesión o cambiar directorios.
El acceso a esta página requiere autorización. Puede intentar cambiar los directorios.
使用 xxHash 算法的 64 位变体计算给定列的哈希代码,并将结果作为长列返回。 哈希计算使用初始种子 42。 支持 Spark Connect。
有关相应的 Databricks SQL 函数,请参阅 xxhash64 函数。
Syntax
from pyspark.databricks.sql import functions as dbf
dbf.xxhash64(*cols)
参数
| 参数 | 类型 | Description |
|---|---|---|
cols |
pyspark.sql.Column 或 str |
要计算的一个或多个列。 |
退货
pyspark.sql.Column:哈希值,长度为列。
例子
示例 1:计算单个列的 xxhash64
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([('ABC', 'DEF')], ['c1', 'c2'])
df.select('*', dbf.xxhash64('c1')).show()
+---+---+-------------------+
| c1| c2| xxhash64(c1)|
+---+---+-------------------+
|ABC|DEF|4105715581806190027|
+---+---+-------------------+
示例 2:计算多个列的 xxhash64
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([('ABC', 'DEF')], ['c1', 'c2'])
df.select('*', dbf.xxhash64('c1', df.c2)).show()
+---+---+-------------------+
| c1| c2| xxhash64(c1, c2)|
+---+---+-------------------+
|ABC|DEF|3233247871021311208|
+---+---+-------------------+