cancel
Showing results for 
Search instead for 
Did you mean: 
Get Started Discussions
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
Honored Contributor
Honored Contributor

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