SleepyBear96 opened a new issue, #9489:
URL: https://github.com/apache/incubator-doris/issues/9489

   ### Search before asking
   
   - [X] I had searched in the 
[issues](https://github.com/apache/incubator-doris/issues?q=is%3Aissue) and 
found no similar issues.
   
   
   ### Version
   
   0.15
   
   ### What's Wrong?
   
   table schema is like: 
   -----------------
   | id    | int         |
   -----------------
   | bit   | bitmap  |
   -----------------
   
   then execute the SQL like:
   
   select bitmap_count(bitmap_intersect(bit)) from table where id in ("aaaaa", 
"bbbbb");
   
   be will coredump.
   
   ### What You Expected?
   
   be don't coredump and get a correct result.
   
   ### How to Reproduce?
   
   _No response_
   
   ### Anything Else?
   
   I had tried to debug it. I fount that the reason of coredump is the is_null 
property of _StringVal_ had been lost when conversion between _StringValue_ and 
_StringVal_. The _StringValue_ doesn't have a _is_null_ variant. So the logic 
in **bitmap_serialize** and **bitmap_intersect** which rely on the _is_null_ 
can't have a right behaviour.
   
   When I do a modification like
   
   void BitmapFunctions::bitmap_intersect(FunctionContext* ctx, const 
StringVal& src, StringVal* dst) {
       if (src.ptr == nullptr) {
           const_cast<StringVal&> (src).is_null = true;
       }
   
       if (dst->is_null == nullptr) {
           dst->is_null = true;
       }
       if (src.is_null) {
           return;
       }
       // if dst is null, the src input is the first value
       if (UNLIKELY(dst->ptr == nullptr)) {
           dst->is_null = false;
           dst->len = sizeof(BitmapValue);
           dst->ptr = (uint8_t*)new BitmapValue((char*)src.ptr);
           return;
       }
       auto dst_bitmap = reinterpret_cast<BitmapValue*>(dst->ptr);
       // zero size means the src input is a agg object
       if (src.len == 0) {
           (*dst_bitmap) &= *reinterpret_cast<BitmapValue*>(src.ptr);
       } else {
           (*dst_bitmap) &= BitmapValue((char*)src.ptr);
       }
   }
   
   StringVal BitmapFunctions::bitmap_serialize(FunctionContext* ctx, const 
StringVal& src) {
       if (src.ptr == nullptr) {
           const_cast<StringVal&> (src).is_null = true;
       }
   
   
       if (src.is_null) {
           return src;
       }
   
       auto src_bitmap = reinterpret_cast<BitmapValue*>(src.ptr);
       StringVal result = serialize(ctx, src_bitmap);
       delete src_bitmap;
       return result;
   }
   
   
   It will not be coredump.
   
   But the result is still wrong.
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to