BITAND Function

Hi Team

I am doing migration from Oracle to BigData using Hive process.
I have a scenario to convert BITAND to Hive but hive did not support BITAND can i know who to over come this function…

Example :-
Oracle Stmt


select
DECODE(BITAND(NVL(S.PRIVILEGE,0), 96), 0, 0, 1) SITE_ADMIN
from
public s

Hive Stmt


thanks in Advance.

You can use Java’s bitwise and operation via UDF.

From the Oracle docs for BITAND:

“The result is computed in several steps. First, each argument A is replaced with the value SIGN(A)*FLOOR(ABS(A)). This conversion has the effect of truncating each argument towards zero. Next, each argument A (which must now be an integer value) is converted to an n-bit two’s complement binary integer value. The two bit values are combined using a bitwise AND operation. Finally, the resulting n-bit two’s complement value is converted back to NUMBER.”

Put simply, this function truncates its arguments, converts them to a binary number (currently limited to 128 bits), AND’s the two binary numbers together, and returns the result of converting the binary number back to a NUMBER.
SHOW FUNCTIONS;
DESCRIBE FUNCTION <function_name>;
DESCRIBE FUNCTION EXTENDED <function_name>;