Skip to main content

kll_sketch_get_n_double

Returns the number of items collected in the KLL double sketch.

Syntax

Python
from pyspark.sql import functions as sf

sf.kll_sketch_get_n_double(col)

Parameters

Parameter

Type

Description

col

pyspark.sql.Column or str

The KLL double sketch binary representation.

Returns

pyspark.sql.Column: The count of items in the sketch.

Examples

Example 1: Get count of items in KLL double sketch

Python
from pyspark.sql import functions as sf
df = spark.createDataFrame([1.0,2.0,3.0,4.0,5.0], "DOUBLE")
sketch_df = df.agg(sf.kll_sketch_agg_double("value").alias("sketch"))
sketch_df.select(sf.kll_sketch_get_n_double("sketch")).show()
Output
+-------------------------------+
|kll_sketch_get_n_double(sketch)|
+-------------------------------+
| 5|
+-------------------------------+