メインコンテンツまでスキップ

シータユニオン

Datasketches Union オブジェクトを使用して、Datasketches ThetaSketch オブジェクトの 2 つのバイナリ表現を結合します。

構文

Python
from pyspark.sql import functions as sf

sf.theta_union(col1, col2, lgNomEntries=None)

パラメーター

パラメーター

Type

説明

col1

pyspark.sql.Column または文字列

最初のThetaスケッチ。

col2

pyspark.sql.Column または文字列

2番目のThetaスケッチ。

lgNomEntries

pyspark.sql.Column または int(オプション)

結合演算の公称エントリの 2 を底とする対数 (4 から 26 までの範囲で指定する必要があり、デフォルトは 12)。

戻り値

pyspark.sql.Column: マージされた ThetaSketch のバイナリ表現。

例1 :2つのThetaスケッチの結合

Python
from pyspark.sql import functions as sf
df = spark.createDataFrame([(1,4),(2,5),(2,5),(3,6)], "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_union(df.sketch1, "sketch2"))).show()
Output
+--------------------------------------------------------+
|theta_sketch_estimate(theta_union(sketch1, sketch2, 12))|
+--------------------------------------------------------+
| 6|
+--------------------------------------------------------+