hll_from_base64

description

Syntax

HLL HLL_FROM_BASE64(VARCHAR input)

将一个base64字符串(hll_to_base64函数的结果)转化为一个HLL。当输入字符串不合法时,返回NULL。

example

查询示例

  1. mysql> select hll_union_agg(hll_from_base64(hll_to_base64(pv))), hll_union_agg(pv) from test_hll;
  2. +---------------------------------------------------+-------------------+
  3. | hll_union_agg(hll_from_base64(hll_to_base64(pv))) | hll_union_agg(pv) |
  4. +---------------------------------------------------+-------------------+
  5. | 3 | 3 |
  6. +---------------------------------------------------+-------------------+
  7. 1 row in set (0.04 sec)
  8. mysql> select hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('abc'))));
  9. +------------------------------------------------------------------+
  10. | hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('abc')))) |
  11. +------------------------------------------------------------------+
  12. | 1 |
  13. +------------------------------------------------------------------+
  14. 1 row in set (0.04 sec)
  15. mysql> select hll_cardinality(hll_from_base64(hll_to_base64(hll_hash(''))));
  16. +---------------------------------------------------------------+
  17. | hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('')))) |
  18. +---------------------------------------------------------------+
  19. | 1 |
  20. +---------------------------------------------------------------+
  21. 1 row in set (0.02 sec)
  22. mysql> select hll_cardinality(hll_from_base64(hll_to_base64(hll_hash(NULL))));
  23. +-----------------------------------------------------------------+
  24. | hll_cardinality(hll_from_base64(hll_to_base64(hll_hash(NULL)))) |
  25. +-----------------------------------------------------------------+
  26. | 0 |
  27. +-----------------------------------------------------------------+
  28. 1 row in set (0.02 sec)

数据导入示例:

  1. 前置条件:
  2. 1. Hive 中已经创建好一个名为 hive_test.hive_hll_table Hive 表(格式为 textfile ,字段为:`k1` int, `k2` String, `k3` String, `uuid` binary),并且已经基于普通表使用 to_hll UDF函数往该表插入数据。
  3. 2. Doris 中创建名为 hive Catalog 用来连接。
  4. 3. 创建好 Doris 内表,名为 doris_hll_table,字段有:`k1` int, `k2` varchar(10), `k3` varchar(10), `uuid` HLL HLL_UNION
  5. 那么,此时可以使用 hll_from_base64 函数从 Hive 插入数据到 Doris 中:
  6. insert into doris_hll_table select k1, k2, k3, hll_from_base64(uuid) from hive.hive_test.hive_hll_table;

更多导入细节可以参考:Hive HLL UDF

keywords

HLL_FROM_BASE64,HLL