mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 09:32:06 +00:00
Merge pull request #33971 from Avogar/fix-ipv6
Fix parsing IPv6 from query parameter and fix IPv6 to string conversion
This commit is contained in:
commit
bf768a94e8
@ -1772,6 +1772,12 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
if constexpr (std::is_same_v<ToDataType, DataTypeString>)
|
||||
{
|
||||
if (from_type->getCustomSerialization())
|
||||
return ConvertImplGenericToString<ColumnString>::execute(arguments, result_type, input_rows_count);
|
||||
}
|
||||
|
||||
bool done;
|
||||
if constexpr (to_string_or_fixed_string)
|
||||
{
|
||||
@ -3409,7 +3415,7 @@ private:
|
||||
return false;
|
||||
};
|
||||
|
||||
auto make_custom_serialization_wrapper = [&](const auto & types) -> bool
|
||||
auto make_custom_serialization_wrapper = [&](const auto & types) -> bool
|
||||
{
|
||||
using Types = std::decay_t<decltype(types)>;
|
||||
using ToDataType = typename Types::RightType;
|
||||
|
@ -69,7 +69,14 @@ void ReplaceQueryParameterVisitor::visitQueryParameter(ASTPtr & ast)
|
||||
" because it isn't parsed completely: only {} of {} bytes was parsed: {}",
|
||||
value, type_name, ast_param.name, read_buffer.count(), value.size(), value.substr(0, read_buffer.count()));
|
||||
|
||||
ast = addTypeConversionToAST(std::make_shared<ASTLiteral>(temp_column[0]), type_name);
|
||||
Field literal;
|
||||
/// If data type has custom serialization, we should use CAST from String,
|
||||
/// because CAST from field may not work correctly (for example for type IPv6).
|
||||
if (data_type->getCustomSerialization())
|
||||
literal = value;
|
||||
else
|
||||
literal = temp_column[0];
|
||||
ast = addTypeConversionToAST(std::make_shared<ASTLiteral>(literal), type_name);
|
||||
|
||||
/// Keep the original alias.
|
||||
ast->setAlias(alias);
|
||||
|
2
tests/queries/0_stateless/02184_ipv6_parsing.reference
Normal file
2
tests/queries/0_stateless/02184_ipv6_parsing.reference
Normal file
@ -0,0 +1,2 @@
|
||||
2001:db9:85a3::8a2e:370:7334
|
||||
2001:db8:85a3::8a2e:370:7334
|
11
tests/queries/0_stateless/02184_ipv6_parsing.sh
Executable file
11
tests/queries/0_stateless/02184_ipv6_parsing.sh
Executable file
@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
# Tags: no-parallel, no-fasttest
|
||||
|
||||
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
# shellcheck source=../shell_config.sh
|
||||
. "$CURDIR"/../shell_config.sh
|
||||
|
||||
|
||||
$CLICKHOUSE_CLIENT -q "select toString(toIPv6('2001:db9:85a3::8a2e:370:7334'))"
|
||||
$CLICKHOUSE_CLIENT --param_var 2001:db8:85a3::8a2e:370:7334 -q "select {var:IPv6}"
|
||||
|
Loading…
Reference in New Issue
Block a user