@@ -44,6 +44,50 @@ SELECT shiftright(col1, 2), shiftright(col1, col2) FROM test
4444query
4545SELECT shiftleft(col1, 2 ), shiftleft(col1, col2) FROM test
4646
47+ -- ShiftRightUnsigned: first arg is Int or Long, second is Int. Returns the
48+ -- same integer type as the first argument. Shift amount is normalized to the
49+ -- bit width (Java semantics) for negative and large shifts.
50+ statement
51+ CREATE TABLE test_shiftrightunsigned_int (v int , s int ) USING parquet
52+
53+ statement
54+ INSERT INTO test_shiftrightunsigned_int VALUES
55+ (1 , 1 ),
56+ (- 1 , 1 ),
57+ (8 , 2 ),
58+ (2147483647 , 1 ),
59+ (- 2147483648 , 1 ),
60+ (0 , 0 ),
61+ (1 , 0 ),
62+ (1 , 31 ),
63+ (1 , 32 ),
64+ (1 , 33 ),
65+ (1 , - 1 ),
66+ (NULL , 1 ),
67+ (1 , NULL )
68+
69+ query
70+ SELECT shiftrightunsigned(v, s) FROM test_shiftrightunsigned_int
71+
72+ statement
73+ CREATE TABLE test_shiftrightunsigned_long (v bigint , s int ) USING parquet
74+
75+ statement
76+ INSERT INTO test_shiftrightunsigned_long VALUES
77+ (1 , 1 ),
78+ (- 1 , 1 ),
79+ (9223372036854775807 , 1 ),
80+ (- 9223372036854775808 , 1 ),
81+ (0 , 0 ),
82+ (1 , 63 ),
83+ (1 , 64 ),
84+ (1 , - 1 ),
85+ (NULL , 1 ),
86+ (1 , NULL )
87+
88+ query
89+ SELECT shiftrightunsigned(v, s) FROM test_shiftrightunsigned_long
90+
4791query
4892SELECT ~(11 ), ~col1, ~col2 FROM test
4993
@@ -79,3 +123,6 @@ SELECT bit_get(11, 0), bit_get(11, 1), bit_get(11, 2), bit_get(11, 3)
79123
80124query
81125SELECT shiftright(1111 , 2 ), shiftleft(1111 , 2 )
126+
127+ query
128+ SELECT shiftrightunsigned(1 , 1 ), shiftrightunsigned(- 1 , 1 ), shiftrightunsigned(2147483647 , 1 ), shiftrightunsigned(cast(- 1 as bigint ), 1 )
0 commit comments