bitmap_or求并集,空集和非空集合的并集为空集

【详述】bitmap_or求并集,空集和非空集合的并集为空集
【StarRocks版本】例如:2.0.0
原始的场景是对两张表where过滤后求并集,在其中一张表非空的情况下,使用 bitmap_or 求出的并集结果为空集。

使用简单的例子进行测试复现

select bitmap_count(bitmap_or(to_bitmap(1), to_bitmap(null))) cnt;
select bitmap_count(bitmap_or(to_bitmap(3), bitmap_or(to_bitmap(null), to_bitmap(4)))) cnt;

select bitmap_count(bitmap_or(to_bitmap(1), to_bitmap(null))) cnt;等价于select bitmap_count(bitmap_or(to_bitmap(1), null)) cnt;
空的bitmap应该是bitmap_empty(),上面的需求应该是
select bitmap_count(bitmap_or(to_bitmap(1), bitmap_empty())) cnt;

感谢答复。

生产中的计算场景如下,在某个子查询为空的情况下,无法求得并集。

with a as (select bitmap_union(to_bitmap(uid)) as bit_col from db_name.t1_name where value = 0)
   , b as (select bitmap_union(to_bitmap(uid)) as bit_col from db_name.t2_name where value in ('value_1','value_2'))
select bitmap_or(a.bit_col,b.bit_col) as bit_col
from a,b;

按照刚刚的纠正,修改sql后可以计算出结果,想问问还有没有更好的建议,感谢感谢

with a as (select if(bitmap_union_count(to_bitmap(uid)) = 0, bitmap_empty(), bitmap_union(to_bitmap(uid))) as bit_col from db_name.t1_name where value = 0) 
   , b as (select if(bitmap_union_count(to_bitmap(uid)) = 0, bitmap_empty(), bitmap_union(to_bitmap(uid))) as bit_col from db_name.t2_name where value in ('value_1','value_2'))
select bitmap_or(a.bit_col,b.bit_col) as bit_col
from a,b;