Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
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
from pyspark.sql import functions as sf
sf.kll_sketch_get_rank_bigint(sketch, quantile)
Parameters
| Parameter | Type | Description |
|---|---|---|
sketch |
pyspark.sql.Column or str |
The KLL bigint sketch binary representation. |
quantile |
pyspark.sql.Column or str |
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
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()
+-------------------------------------+
|kll_sketch_get_rank_bigint(sketch, 3)|
+-------------------------------------+
| 0.6|
+-------------------------------------+