Ipv4 can be represented as a subset of ipv6 using :ffff:1
select IPv6NumToString(IPv4ToIPv6(toIPv4('127.0.0.1')));
┌─IPv6NumToString(IPv4ToIPv6(toIPv4('127.0.0.1')))─┐
│ ::ffff:127.0.0.1 │
└──────────────────────────────────────────────────┘
Probably it's better to convert in such form before inserting into CH
create table tip6(i IPv6) Engine=Memory;
insert into tip6 values('::ffff:127.0.0.1'), ('2001:44c8:129:2632:33:0:252:2');
select * from tip6 ;
┌─i─────────────────────────────┐
│ ::ffff:127.0.0.1 │
│ 2001:44c8:129:2632:33:0:252:2 │
└───────────────────────────────┘
During the transition of the Internet from IPv4 to IPv6, it is typical
to operate in a mixed addressing environment. For such use cases, a
special notation has been introduced, which expresses IPv4-mapped and
IPv4-compatible IPv6 addresses by writing the least-significant 32 bits
of an address in the familiar IPv4 dot-decimal notation, whereas the 96 most-significant bits are written in IPv6 format. For example, the IPv4-mapped IPv6 address ::ffff:c000:0280 is written as ::ffff:192.0.2.128, thus expressing clearly the original IPv4 address that was mapped to IPv6.