Clickhouse: function for convert hex to number?

Created on 20 Jul 2018  Β·  5Comments  Β·  Source: ClickHouse/ClickHouse

is there a function?

question

Most helpful comment

@salisbury-espinosa The last sentence of that article says how to convert those bytes to a number:

SELECT reinterpretAsInt64(reverse(unhex('123')))

β”Œβ”€reinterpretAsInt64(reverse(unhex('123')))─┐
β”‚                                       291 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
% python
Python 2.7.6 (default, Oct 26 2016, 20:30:19)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 0x123
291

All 5 comments

@blinkov
unhex(str)
returns a string containing the corresponding bytes
it's not that

@salisbury-espinosa The last sentence of that article says how to convert those bytes to a number:

SELECT reinterpretAsInt64(reverse(unhex('123')))

β”Œβ”€reinterpretAsInt64(reverse(unhex('123')))─┐
β”‚                                       291 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
% python
Python 2.7.6 (default, Oct 26 2016, 20:30:19)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 0x123
291

@blinkov oh, I saw this. thank you)

you're welcome

Was this page helpful?
0 / 5 - 0 ratings