You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are already some IPv6-related functions (IPv6NumToString and IPv6StringToNum) that help with the type conversion between the user-readable IPv6 address and the FixedString(16)'s value.
It would appear handy to have such like those, but for the UUIDs - it's a pretty common format and it is a bit of pain to work with at the moment:
:) INSERT INTO test (uuid) VALUES (unhex(replaceAll('0964c739-b150-4312-924f-01352d3a4a56', '-', '')));
Ok.
:) SELECT uuid as uuid_binary, replaceRegexpOne(lower(hex(uuid)), '(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w{12})', '\\1-\\2-\\3-\\4-\\5') AS uuid_decoded
FROM test;
┌─uuid_binary─────┬─uuid_decoded──────────────────────────┐
│ \td�9�PC�O5-:JV │ 0964c739-b150-4312-924f-01352d3a4a56 │
└─────────────────┴───────────────────────────────────────┘
I was thinking of a bunch of substring/concat's to improve performance, but it looked much, much uglier :)
Functions UUIDNumToString() and UUIDStringToNum() were implemented in d77b4f1 and 31dbff7 by @alexey-milovidov. (#METR-23792)
Thanks a lot!
I also referenced these functions in the documentation. Pull request's on its way.
By the way - just wondering - are we historically keeping NumToString/StringToNum naming convention?
There is, indeed, IPv4StringToNum, which fits an integer, but IPv6 and UUID are stored in FixedString(16).
Wouldn't it be better to use something like UUIDBinaryToString or UUIDBytesToString instead?
I understand that we probably shouldn't rename IPv6-related functions because of the compatibility issues, but on UUIDs it seems to be more straight-forward.
By the way - just wondering - are we historically keeping NumToString/StringToNum naming convention?
There is, indeed, IPv4StringToNum, which fits an integer, but IPv6 and UUID are stored in FixedString(16).
Yes. Now we are using "Num" only for consistency with other functions. "Binary" will suite better than "Num". I hope, we will soon introduce function synonims (main reason - to add standard compatible names for existing functions), and we will add IPv6StringToBinary, IPv6BinaryToString, UUIDStringToBinary, UUIDBinaryToString.
Activity
alexey-milovidov commentedon Sep 29, 2016
Yes, proposed
UUIDNumToString,UUIDStringToNumfunctions would be much more convenient.Implementation is simple.
hatarist commentedon Dec 12, 2016
Functions
UUIDNumToString()andUUIDStringToNum()were implemented in d77b4f1 and 31dbff7 by @alexey-milovidov. (#METR-23792)Thanks a lot!
I also referenced these functions in the documentation. Pull request's on its way.
By the way - just wondering - are we historically keeping
NumToString/StringToNumnaming convention?There is, indeed,
IPv4StringToNum, which fits an integer, but IPv6 and UUID are stored in FixedString(16).Wouldn't it be better to use something like
UUIDBinaryToStringorUUIDBytesToStringinstead?I understand that we probably shouldn't rename IPv6-related functions because of the compatibility issues, but on UUIDs it seems to be more straight-forward.
Merge pull request #244 from hatarist/reference_uuids
alexey-milovidov commentedon Dec 12, 2016
Yes. Now we are using "Num" only for consistency with other functions. "Binary" will suite better than "Num". I hope, we will soon introduce function synonims (main reason - to add standard compatible names for existing functions), and we will add
IPv6StringToBinary,IPv6BinaryToString,UUIDStringToBinary,UUIDBinaryToString.DOCS-625: system.query_thread_log (#11437)