You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2019/10/17 05:50:53 UTC

[GitHub] [spark] yaooqinn commented on a change in pull request #26139: [SPARK-29491][SQL] Add bit_count function support

yaooqinn commented on a change in pull request #26139: [SPARK-29491][SQL] Add bit_count function support
URL: https://github.com/apache/spark/pull/26139#discussion_r335819124
 
 

 ##########
 File path: sql/core/src/test/resources/sql-tests/inputs/bitwise.sql
 ##########
 @@ -0,0 +1,44 @@
+-- test cases for bitwise functions
+
+-- null
+
+select bit_count(null);
+
+-- boolean
+select bit_count(true);
+select bit_count(false);
+
+-- byte/tinyint
+select bit_count(cast(1 as tinyint));
+select bit_count(cast(2 as tinyint));
+select bit_count(cast(3 as tinyint));
+
+-- short/smallint
+select bit_count(1S);
+select bit_count(2S);
+select bit_count(3S);
+
+-- int
+select bit_count(1);
+select bit_count(2);
+select bit_count(3);
+
+-- long/bigint
+select bit_count(1L);
+select bit_count(2L);
+select bit_count(3L);
+
+-- negative num
+select bit_count(-1L);
+
+-- mysql> select 9223372036854775807 + 1;
+-- ERROR 1690 (22003): BIGINT value is out of range in '(9223372036854775807 + 1)'
+-- mysql> select bit_count(9223372036854775807 + 1);
+-- ERROR 1690 (22003): BIGINT value is out of range in '(9223372036854775807 + 1)'
+-- out of range
+select 9223372036854775807L + 1L;
+select bit_count(9223372036854775807L + 1L);
 
 Review comment:
   ```mysql
   mysql> select bit_count(-9223372036854775808);
   +---------------------------------+
   | bit_count(-9223372036854775808) |
   +---------------------------------+
   |                               1 |
   +---------------------------------+
   1 row in set (0.01 sec)
   
   mysql> select bit_count(9223372036854775807);
   +--------------------------------+
   | bit_count(9223372036854775807) |
   +--------------------------------+
   |                             63 |
   +--------------------------------+
   1 row in set (0.00 sec)
   
   mysql> select bit_count(9223372036854775807 + 1);
   ERROR 1690 (22003): BIGINT value is out of range in '(9223372036854775807 + 1)'
   ```

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org