Las funciones uniqTheta operan sobre dos objetos uniqThetaSketch para realizar cálculos de operaciones de conjuntos como ∪ / ∩ / × (union/intersect/not) y devuelven un nuevo objeto uniqThetaSketch que contiene el resultado.
Un objeto uniqThetaSketch se construye mediante la función de agregación uniqTheta con -State.
UniqThetaSketch es una estructura de datos para almacenar conjuntos de valores aproximados.
Para obtener más información, consulte: Theta Sketch Framework.
Dos objetos uniqThetaSketch para realizar una unión (operación de conjuntos ∪); el resultado es un nuevo uniqThetaSketch.
uniqThetaUnion(uniqThetaSketch,uniqThetaSketch)
Argumentos
uniqThetaSketch – objeto uniqThetaSketch.
Ejemplo
SELECT finalizeAggregation(uniqThetaUnion(a, b)) AS a_union_b, finalizeAggregation(a) AS a_cardinality, finalizeAggregation(b) AS b_cardinality
FROM
(SELECT arrayReduce('uniqThetaState',[1,2]) AS a, arrayReduce('uniqThetaState',[2,3,4]) AS b );
┌─a_union_b─┬─a_cardinality─┬─b_cardinality─┐
│ 4 │ 2 │ 3 │
└───────────┴───────────────┴───────────────┘
Dos objetos uniqThetaSketch para calcular su intersección (operación de conjuntos ∩); el resultado es un nuevo uniqThetaSketch.
uniqThetaIntersect(uniqThetaSketch,uniqThetaSketch)
Argumentos
uniqThetaSketch – objeto uniqThetaSketch.
Ejemplo
SELECT finalizeAggregation(uniqThetaIntersect(a, b)) AS a_intersect_b, finalizeAggregation(a) AS a_cardinality, finalizeAggregation(b) AS b_cardinality
FROM
(SELECT arrayReduce('uniqThetaState',[1,2]) AS a, arrayReduce('uniqThetaState',[2,3,4]) AS b );
┌─a_intersect_b─┬─a_cardinality─┬─b_cardinality─┐
│ 1 │ 2 │ 3 │
└───────────────┴───────────────┴───────────────┘
Dos objetos uniqThetaSketch para realizar un cálculo a_not_b (operación de conjuntos ×); el resultado es un nuevo uniqThetaSketch.
uniqThetaNot(uniqThetaSketch,uniqThetaSketch)
Argumentos
uniqThetaSketch – objeto uniqThetaSketch.
Ejemplo
SELECT finalizeAggregation(uniqThetaNot(a, b)) AS a_not_b, finalizeAggregation(a) AS a_cardinality, finalizeAggregation(b) AS b_cardinality
FROM
(SELECT arrayReduce('uniqThetaState',[2,3,4]) AS a, arrayReduce('uniqThetaState',[1,2]) AS b );
┌─a_not_b─┬─a_cardinality─┬─b_cardinality─┐
│ 2 │ 3 │ 2 │
└─────────┴───────────────┴───────────────┘
Véase también
Última modificación el 10 de junio de 2026