diff --git a/src/Functions/FunctionsCodingIP.h b/src/Functions/FunctionsCodingIP.h index 8f55a106e5a..f25b25b12f0 100644 --- a/src/Functions/FunctionsCodingIP.h +++ b/src/Functions/FunctionsCodingIP.h @@ -87,7 +87,7 @@ namespace detail if (null_map && (*null_map)[i]) { - vec_res[i] = 0; + std::fill_n(&vec_res[i], IPV6_BINARY_LENGTH, 0); src_offset = src_next_offset; if constexpr (exception_mode == IPStringToNumExceptionMode::Null) (*vec_null_map_to)[i] = true; diff --git a/tests/queries/0_stateless/02303_cast_nullable_to_custom_types.reference b/tests/queries/0_stateless/02303_cast_nullable_to_custom_types.reference index 50eae1e83ac..159ee805f26 100644 --- a/tests/queries/0_stateless/02303_cast_nullable_to_custom_types.reference +++ b/tests/queries/0_stateless/02303_cast_nullable_to_custom_types.reference @@ -17,8 +17,16 @@ true \N 0.0.0.0 \N +0.0.0.0 +\N +\N +\N 0 \N :: \N +:: +\N +\N +\N \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0 diff --git a/tests/queries/0_stateless/02303_cast_nullable_to_custom_types.sql b/tests/queries/0_stateless/02303_cast_nullable_to_custom_types.sql index 1321053fa72..1a0d9a4c830 100644 --- a/tests/queries/0_stateless/02303_cast_nullable_to_custom_types.sql +++ b/tests/queries/0_stateless/02303_cast_nullable_to_custom_types.sql @@ -14,7 +14,10 @@ select CAST(number % 2 ? '0000:0000:0000:0000:0000:0000:0000:0000' : NULL, 'Null select toBool(number % 2 ? 'true' : NULL) from numbers(2); select toIPv4(number % 2 ? '0.0.0.0' : NULL) from numbers(2); +select toIPv4OrDefault(number % 2 ? '' : NULL) from numbers(2); +select toIPv4OrNull(number % 2 ? '' : NULL) from numbers(2); select IPv4StringToNum(number % 2 ? '0.0.0.0' : NULL) from numbers(2); select toIPv6(number % 2 ? '0000:0000:0000:0000:0000:0000:0000:0000' : NULL) from numbers(2); +select toIPv6OrDefault(number % 2 ? '' : NULL) from numbers(2); +select toIPv6OrNull(number % 2 ? '' : NULL) from numbers(2); select IPv6StringToNum(number % 2 ? '0000:0000:0000:0000:0000:0000:0000:0000' : NULL) from numbers(2); -