zhiqiang-hhhh opened a new pull request, #30046:
URL: https://github.com/apache/doris/pull/30046

   1. bit_count(x): return the exist count of one in 2's complement represent 
of integer x.
   2. bit_shift_left(x, c): do logical left shift to x by c bits, and return 
result as a BIGINT.
   3. bit_shift_right(x, c): do logical right shift to x by c bits, and return 
result as a BIGINT.
   
   NOTE: bit_shift will return same type with x, so bit_shift_left(BIGINT_MAX, 
1) will get -1
   
   ```sql
   WITH my_cte AS (   SELECT 9223372036854775807 AS BIGINT_MAX ) SELECT 
BIGINT_MAX, bit_count(BIGINT_MAX) FROM my_cte
   --------------
   
   +---------------------+-----------------------+
   | BIGINT_MAX          | bit_count(BIGINT_MAX) |
   +---------------------+-----------------------+
   | 9223372036854775807 |                    63 |
   +---------------------+-----------------------+
   1 row in set (0.02 sec)
   
   WITH my_cte AS (   SELECT 9223372036854775807 AS BIGINT_MAX ) SELECT 
BIGINT_MAX, bit_shift_left(BIGINT_MAX, 1) FROM my_cte
   --------------
   
   +---------------------+-------------------------------+
   | BIGINT_MAX          | bit_shift_left(BIGINT_MAX, 1) |
   +---------------------+-------------------------------+
   | 9223372036854775807 |                            -2 |
   +---------------------+-------------------------------+
   1 row in set (0.01 sec)
   
   WITH my_cte AS (   SELECT 9223372036854775807 AS BIGINT_MAX ) SELECT 
BIGINT_MAX, bit_shift_right(BIGINT_MAX, 62) FROM my_cte
   --------------
   
   +---------------------+-----------------------------------+
   | BIGINT_MAX          | bit_shift_right(`BIGINT_MAX`, 62) |
   +---------------------+-----------------------------------+
   | 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.

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