clickhouse.rs icon indicating copy to clipboard operation
clickhouse.rs copied to clipboard

Support `std::net::Ipv4Addr` without a custom serde attribute

Open slvrtrn opened this issue 6 months ago • 2 comments

Only after #221.

If we somehow implement a conditional ReverseSeqAccess, e.g., via the InnerDataTypeValidator, adding a new branch like ReversedArray, then we can get rid of custom serde for IPv4 and just use plain std::net::Ipv4Addr, similarly to std::net::Ipv6Addr.

Currently, without the serde attribute, the IPv4 ends up being reversed. This is slightly annoying, since IPv6 does not require any special treatment.

IIUIC, that is because ClickHouse stores IPv4 as a little-endian UInt32, but serde by default calls deserialization on [u8; 4] as IPv4 can be constructed from a big-endian byte array representing u32.

slvrtrn avatar Jun 09 '25 11:06 slvrtrn

Should this feature also be valid for queries with no validation?

ozgurcancal avatar Jul 02 '25 13:07 ozgurcancal

We can't support it without validation, cause we have no access to schema, and we won't be able to figure out that that is an IPv4, as serde calls just deserialize_tuple IIRC. But let's wait until the insert is merged, too

slvrtrn avatar Jul 02 '25 17:07 slvrtrn