pyspark.sql.functions.kll_sketch_get_rank_float#

pyspark.sql.functions.kll_sketch_get_rank_float(sketch, quantile)[source]#

Extracts a rank value from a KLL float sketch given an input quantile value. The quantile can be a single value or an array.

Added in version 4.1.0.

Parameters:
sketchColumn or column name

The KLL float sketch binary representation. A column that evaluates to a binary.

quantileColumn or column name

The quantile value(s) to lookup. A column that evaluates to a float or array. Must be a constant.

Returns:
Column

The rank value(s) (between 0.0 and 1.0). Returns a column that evaluates to a double, or an array of doubles if the quantile argument is an array.

Examples

>>> 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()
+--------------------------------------+
|kll_sketch_get_rank_float(sketch, 3.0)|
+--------------------------------------+
|                                   0.6|
+--------------------------------------+