You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Doris中查询Bitmap/HLL类型返回NULL的原因及解决方法

Doris查询Bitmap/HLL返回NULL的解决方法

问题原因

Doris中的Bitmap、HLL属于聚合类型列,这类列存储的是聚合计算后的中间状态,并非直接可展示的原始数据。直接使用select *或单独查询列名时,客户端无法解析其内部存储格式,因此返回NULL,这是正常的设计特性,并非执行失败。

修复方法

针对Bitmap和HLL类型,需要使用对应的函数来解析或计算其实际值:

1. Bitmap类型处理

  • 查看Bitmap中的具体元素:使用bitmap_to_string()函数,将Bitmap转换为逗号分隔的字符串
  • 统计Bitmap的基数(去重后元素数量):使用bitmap_count()函数

示例执行:

-- 查看Bitmap具体元素
select typ_id, hou, bitmap_to_string(arr) from test_bitmap;

-- 统计Bitmap基数
select typ_id, hou, bitmap_count(arr) from test_bitmap;

执行结果示例:

mysql> select typ_id, hou, bitmap_to_string(arr) from test_bitmap;
+--------+------+-----------------------+
| typ_id | hou  | bitmap_to_string(arr) |
+--------+------+-----------------------+
|      1 | one  | 1                     |
+--------+------+-----------------------+
1 row in set (0.03 sec)

mysql> select typ_id, hou, bitmap_count(arr) from test_bitmap;
+--------+------+-------------------+
| typ_id | hou  | bitmap_count(arr) |
+--------+------+-------------------+
|      1 | one  |                 1 |
+--------+------+-------------------+
1 row in set (0.02 sec)

2. HLL类型处理

如果是HLL列,常用函数:

  • 计算HLL的基数:hll_cardinality(hll_col)
  • 聚合HLL数据:hll_union_agg(hll_col)

注意事项

  • 聚合类型列(Bitmap/HLL)仅在聚合模型(AGGREGATE KEY)或更新模型(UNIQUE KEY)中作为聚合字段使用,不能作为普通列直接展示
  • 插入数据时需使用to_bitmap()(Bitmap)或hll_hash()(HLL)函数将原始值转换为对应类型

内容的提问来源于stack exchange,提问作者user8589466

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.13 00:59:55