ViewWholeWorld opened a new issue, #18040:
URL: https://github.com/apache/doris/issues/18040

   ### Search before asking
   
   - [X] I had searched in the 
[issues](https://github.com/apache/doris/issues?q=is%3Aissue) and found no 
similar issues.
   
   
   ### Description
   
   I have a table like this:
   <img width="901" alt="image" 
src="https://user-images.githubusercontent.com/19160255/227080679-effcac7b-1844-4124-8ceb-71911ce5e865.png";>
   Then, I want to calculate the intersection of the bitmap between today and 
yesterday, so I tried the lag function like 
   ```
   select ds,  
       tag_name,
       tag_value,
       user_ids as users_bitmap,
       lag(user_ids, 1, bitmap_empty()) over (partition by tag_name order by ds 
desc) yesterday_bitmap
   from ads_tags_bitmap
   where tag_name = 'gender'
       and tag_value = '男'
       and ds >= '2023-03-19'
       and ds <= '2023-03-21'
   order by ds
   ```
   
   but I got an error
   
   > No matching function with signature: lag(bitmap, bigint(20), bitmap) 
error. 
   
   So, I have to convert bitmap to string and convert it back like below 
   ```
   select ds,
       tag_name,
       tag_value,
       user_ids as users_bitmap,
       bitmap_from_string(lag(bitmap_to_string(user_ids), 1, '')
       over (partition by tag_name order by ds)) yesterday_bitmap
   from ads_tags_bitmap
   where tag_name = 'gender'
       and tag_value = '男'
       and ds >= '2023-03-19'
       and ds <= '2023-03-21'
   order by ds
   ```
   
   ### Use case
   
   As I mentioned before, if the lead/lag function could support bitmap type, 
users can easily solve the problem with the first SQL I used.
   
   ### Related issues
   
   _No response_
   
   ### 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