Aller au contenu principal

theta_intersection

Renvoie l'intersection de deux représentations binaires d'objets Datasketches Theta Sketch, à l'aide d'un objet Intersection Datasketches.

Syntaxe

Python
from pyspark.sql import functions as sf

sf.theta_intersection(col1, col2)

parameter

parameter

Type

Description

col1

pyspark.sql.Column ou str

Le premier Theta sketch.

col2

pyspark.sql.Column ou str

Le deuxième schéma Theta.

parameter

Type

Description

col1

pyspark.sql.Column ou str

Le premier Theta sketch.

col2

pyspark.sql.Column ou str

Le deuxième schéma Theta.

Renvoie

pyspark.sql.Column: La représentation binaire du Theta Sketch intersecté.

Exemples

**Exemple 1** : Obtenir l'intersection de deux esquisses thêta

Python
from pyspark.sql import functions as sf
df = spark.createDataFrame([(1,1),(2,2),(3,2),(3,3)], "struct<v1:int,v2:int>")
df = df.agg(
sf.theta_sketch_agg("v1").alias("sketch1"),
sf.theta_sketch_agg("v2").alias("sketch2")
)
df.select(sf.theta_sketch_estimate(sf.theta_intersection(df.sketch1, "sketch2"))).show()
Output
+-----------------------------------------------------------+
|theta_sketch_estimate(theta_intersection(sketch1, sketch2))|
+-----------------------------------------------------------+
| 3|
+-----------------------------------------------------------+