我在使用Doris求bitmap交集的函数--bitmap_intersect时遇到一个问题:
执行:
select bitmap_count(bitmap_intersect(uid))
from userprofile_label_mid_hive
where (labelid = 'people_sta_bind_days' and labelweiht = '999.0')
or (labelid = 'people_sta_sex_01' and labelweiht= '1.0')
执行结果返回 0。
但是执行:
select bitmap_count(bitmap_intersect(uid))
from (
select uid
from userprofile_label_mid_hive
where (labelid = 'people_sta_bind_days' and labelweiht = '999.0')
or (labelid = 'people_sta_sex_01' and labelweiht= '1.0')
union all
select null
) as aa
执行结果返回 266。 266是正确的。
同样的,我将where条件拆开:
select bitmap_count(bitmap_intersect(uid))
from
(
select uid from userprofile_label_mid_hive
where labelid = 'people_sta_bind_days' and labelweiht = '999.0'
union all
select uid from userprofile_label_mid_hive
where labelid = 'people_sta_sex_01' and labelweiht= '1.0'
) as aa
执行结果也是返回 266。
这3条SQL语句的逻辑是一样的,为什么第1条SQL语句得出来的数是0?
下面是我的建表语句:
CREATE TABLE userprofile_label_mid_hive
(
labelid
varchar(50) NULL COMMENT "",
labelweiht
varchar(50) NULL COMMENT "",
uid
bitmap BITMAP_UNION NULL COMMENT ""
) ENGINE=OLAP
AGGREGATE KEY(labelid
, labelweiht
)
COMMENT "OLAP"
DISTRIBUTED BY HASH(labelid
) BUCKETS 1
PROPERTIES (
"replication_allocation" = "tag.location.default: 3",
"in_memory" = "false",
"storage_format" = "V2"