cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Get Started Discussions
Start your journey with Databricks by joining discussions on getting started guides, tutorials, and introductory topics. Connect with beginners and experts alike to kickstart your Databricks experience.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

bitmap_count() function's output is different in databricks compared to snowflake

vigneshp
New Contributor

I have found that the results of the bitmap_count() function output differs significantly between databricks and snowflake.

eg: snowflake returns a value of '1' for this code. "select bitmap_count(X'0001056c000000000000') "

vigneshp_1-1701992518337.png

 

while  Databricks returns a value of '7' . 

vigneshp_0-1701992493192.png

 

does anyone know the reason for this difference? Am I doing anything wrong here? This is part of a migration project. 

Similar to the bitmap_count() function , the bitmap_or_agg() function also works differently, it databricks it pads a lot of zeroes at the end.

 

1 REPLY 1

Ayushi_Suthar
Databricks Employee
Databricks Employee

Hi @vigneshp , Good Day! 

In Databricks, bitmap_count function returns the number of bits set in a BINARY string representing a bitmap. This function is typically used to count distinct values in combination with the bitmap_bucket_number() and the bitmap_construct_agg() functions.

For more details about this function, you can refer to this document : 

https://docs.databricks.com/en/sql/language-manual/functions/bitmap_count.html

Please let me know if this helps and leave a like if this information is useful, followups are appreciated.
Kudos
Ayushi

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group