Skip to content

[to_bitmap] the behavior of to_bitmap() function is inconsistent #3570

@morningman

Description

@morningman

Describe the bug

case 1:

mysql> select to_bitmap(null);
+-----------------+
| to_bitmap(NULL) |
+-----------------+
| NULL            |
+-----------------+
1 row in set (0.01 sec)

It returns NULL because for null parameter, the function will return null. (directly rewrote by FE planner).

Case 2:

mysql> select bitmap_union_count(to_bitmap(k2)) from tbl5;
+-------------------------------------+
| bitmap_union_count(to_bitmap(`k2`)) |
+-------------------------------------+
|                                   0 |
+-------------------------------------+
1 row in set (0.02 sec)

The column k2 in tbl5 is null. And to_bitmap(k2) return an empty bitmap.

Case 3:

mysql> select bitmap_union_count(to_bimap(null)) from tbl5;
ERROR 1064 (HY000): errCode = 2, detailMessage = No matching function with signature: to_bimap(unknown type: NULL_TYPE).

I expected this return 0, but error returns.

Expected behavior

Should the method to_bitmap() be null protected? Which means to_bitmap(null) should always return an empty bitmap, not null.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions