```sql
CREATE TABLE test_tbl
(   `ip` String, `ipv6` IPv6 MATERIALIZED toIPv6(ip) )
ENGINE = Memory;

insert into test_tbl(ip) values ( 'fe80::9801:43ff:fe1f:7690'), ('1.1.1.1'), (''), ('::ffff:1.1.1.1' );

 DB::Exception: Invalid IPv6 value: while executing 'FUNCTION _CAST(toIPv6(ip) :: 2, 'IPv6' :: 1)


set cast_ipv4_ipv6_default_on_conversion_error=1;
insert into test_tbl(ip) values ( 'fe80::9801:43ff:fe1f:7690'), ('1.1.1.1'), (''), ('::ffff:1.1.1.1' );
 
 DB::Exception: Invalid IPv6 value: while executing 'FUNCTION _CAST(toIPv6(ip)
```

`toIPv6OrDefault` does not help in this case.

```sql
CREATE TABLE test_tbl
(   `ip` String, `ipv6` IPv6 MATERIALIZED toIPv6OrDefault(ip) )
ENGINE = Memory;

insert into test_tbl(ip) values ( 'fe80::9801:43ff:fe1f:7690'), ('1.1.1.1'), (''), ('::ffff:1.1.1.1' );
  DB::Exception: Invalid IPv6 value: while executing 'FUNCTION _CAST(toIPv6OrD

insert into test_tbl(ip) values ( 'fe80::9801:43ff:fe1f:7690'), ('1.1.1.1'), (''), ('::ffff:1.1.1.1' ), ('garbudge');
  DB::Exception: Invalid IPv6 value: while executing 'FUNCTION
```

WA:

```sql
CREATE TABLE test_tbl
(   `ip` String, `ipv6` IPv6 MATERIALIZED if(ip='', '::', ip) )
ENGINE = Memory;

insert into test_tbl(ip) values ( 'fe80::9801:43ff:fe1f:7690'), ('1.1.1.1'), (''), ('::ffff:1.1.1.1' );

select ip, ipv6 from test_tbl;
┌─ip────────────────────────┬─ipv6──────────────────────┐
│ fe80::9801:43ff:fe1f:7690 │ fe80::9801:43ff:fe1f:7690 │
│ 1.1.1.1                   │ ::ffff:1.1.1.1            │
│                           │ ::                        │
│ ::ffff:1.1.1.1            │ ::ffff:1.1.1.1            │
└───────────────────────────┴───────────────────────────┘
```
{
    const auto * col = checkAndGetColumn<ColumnUInt32>(&column);
    if (!col)
    {
        throw Exception("IPv4 type can only serialize columns of type UInt32." + column.getName(), ErrorCodes::ILLEGAL_COLUMN);
    }
    char buffer[IPV4_MAX_TEXT_LENGTH + 1] = {'\0'};
    char * ptr = buffer;
    formatIPv4(reinterpret_cast<const unsigned char *>(&col->getData()[row_num]), ptr);
    ostr.write(buffer, strlen(buffer));
}
void SerializationIPv4::deserializeText(IColumn & column, ReadBuffer & istr, const FormatSettings & settings, bool whole) const
{
    ColumnUInt32 * col = typeid_cast<ColumnUInt32 *>(&column);
    if (!col)
    {
        throw Exception("IPv4 type can only deserialize columns of type UInt32." + column.getName(), ErrorCodes::ILLEGAL_COLUMN);
    }
    char buffer[IPV4_MAX_TEXT_LENGTH + 1] = {'\0'};
    istr.read(buffer, sizeof(buffer) - 1);
    UInt32 ipv4_value = 0;
    if (!parseIPv4(buffer, reinterpret_cast<unsigned char *>(&ipv4_value)))
    {
        throw Exception("Invalid IPv4 value.", ErrorCodes::CANNOT_PARSE_DOMAIN_VALUE_FROM_STRING);
    }
    col->insert(ipv4_value);
    if (whole && !istr.eof())
        throwUnexpectedDataAfterParsedValue(column, istr, settings, "IPv4");
}
SerializationIPv6::SerializationIPv6(const SerializationPtr & nested_)