- 类别:
:doc:`/sql-reference/functions-aggregation`(相似性估算)、:doc:`窗口函数 </sql-reference/functions-window-syntax>`(相似性估算)
MINHASH¶
返回 MinHash 状态,此状态包含一个大小为 k 的数组,该数组的构造方式为:向输入行应用 k 个不同哈希函数,并保留每个哈希函数的最小值。然后,可以将此 MinHash 状态输入到 APPROXIMATE_SIMILARITY 函数中,以估计与一个或多个其他 MinHash 状态的相似性。
有关 MinHash 状态的更多信息,请参阅 估计两个或多个集合的相似度。
- 另请参阅:
语法¶
聚合函数
窗口函数
有关 OVER 子句的详细信息,请参阅 窗口函数的语法和用法。
实参¶
k要创建的哈希函数的数量。该值越大,近似值越准确;但是,此值对使用 APPROXIMATE_SIMILARITY 相似性估算的计算时间具有线性影响。建议值为 100。最大值为 1024。
expr一个或多个表达式(通常是列名),用于确定要哈希的值。
*对输入行中的所有列进行哈希处理。
使用说明¶
示例¶
Here is a more extensive example, showing the three related functions
MINHASH, MINHASH_COMBINE and APPROXIMATE_SIMILARITY. This
example creates 3 tables (ta, tb, and tc), two of which (ta and tb) are
similar, and two of which (ta and tc) are completely dissimilar.
创建并使用以下值填充表:
计算初始数据集的 minhash 信息:
向其中一个表添加更多数据:
Demonstrate the MINHASH_COMBINE function:
This query shows the approximate similarity of the two similar tables
(ta and tb):
This query shows the approximate similarity of the two very different tables
(ta and tc):