- 类别:
:doc:`/sql-reference/functions-aggregation`(基数估算)、:doc:`窗口函数 </sql-reference/functions-window-syntax>`(基数估算)
HLL_ESTIMATE¶
返回给定 HyperLogLog 状态的基数估计值。
由 HLL_ACCUMULATE 和 HLL_COMBINE 生成的 HyperLogLog 状态可用于使用 HLL_ESTIMATE 函数计算基数估计值。
因此,HLL_ESTIMATE(HLL_ACCUMULATE(...)) 等效于 HLL(...)。
- 另请参阅:
语法¶
聚合函数
窗口函数
有关 OVER 子句的详细信息,请参阅 窗口函数的语法和用法。
实参¶
state一个表达式,其中包含通过调用 HLL_ACCUMULATE 或 HLL_COMBINE 生成的状态信息。
使用说明¶
示例¶
This example shows how to use the three related functions HLL_ACCUMULATE, HLL_ESTIMATE, and HLL_COMBINE.
创建简单的表和数据:
Create a table that contains the "state" that represents the current
approximate cardinality information for the table named sequence_demo:
Now create a second table and add data. (In a more realistic situation, the user could have loaded more data into the first table and divided the data into non-overlapping sets based on the time that the data was loaded.)
仅获取新数据的“状态”信息。
合并两批行的“状态”信息:
获取行组合集的近似基数: