kll_sketch_get_rank_bigint
Extracts a rank value from a KLL bigint sketch given an input quantile value. The quantile can be a single value or an array.
Syntax
Python
from pyspark.sql import functions as sf
sf.kll_sketch_get_rank_bigint(sketch, quantile)
Parameters
Parameter | Type | Description |
|---|---|---|
|
| The KLL bigint sketch binary representation. |
|
| The quantile value(s) to lookup. |
Returns
pyspark.sql.Column: The rank value(s) (between 0.0 and 1.0).
Examples
Example 1: Get rank from KLL bigint sketch
Python
from pyspark.sql import functions as sf
df = spark.createDataFrame([1,2,3,4,5], "INT")
sketch_df = df.agg(sf.kll_sketch_agg_bigint("value").alias("sketch"))
sketch_df.select(sf.kll_sketch_get_rank_bigint("sketch", sf.lit(3))).show()
Output
+-------------------------------------+
|kll_sketch_get_rank_bigint(sketch, 3)|
+-------------------------------------+
| 0.6|
+-------------------------------------+