kll_sketch_get_rank_float
Extracts a rank value from a KLL float 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_float(sketch, quantile)
Parameters
Parameter | Type | Description |
|---|---|---|
|
| The KLL float 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 float sketch
Python
from pyspark.sql import functions as sf
df = spark.createDataFrame([1.0,2.0,3.0,4.0,5.0], "FLOAT")
sketch_df = df.agg(sf.kll_sketch_agg_float("value").alias("sketch"))
sketch_df.select(sf.kll_sketch_get_rank_float("sketch", sf.lit(3.0))).show()
Output
+--------------------------------------+
|kll_sketch_get_rank_float(sketch, 3.0)|
+--------------------------------------+
| 0.6|
+--------------------------------------+