Reputation: 110382
How would I convert a BYTES
value into INT
? For example, the bitwise operations, |
, ^
, &
, >>
, <<
are defined on both BYTES
and INT
, and so the following both work:
SELECT 97 << 0;
SELECT b'a' << 0;
Is there a way to convert a BYTES
value into INT
, for example, I believe b'a
would evaluate to 97
if a little-endian number UINT32
, I think.
Is there a way to do something like:
SELECT CAST(b'a' AS INT) << 0;
To get the decimal value 97
?
Upvotes: 0
Views: 1527
Reputation: 12254
There may be other ways, but
SELECT TO_CODE_POINTS(b'a')[OFFSET(0)] << 0;
+-----+
| f0_ |
+-----+
| 97 |
+-----+
Upvotes: 1