Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
4df1983d
C
ClickHouse
项目概览
2dot5
/
ClickHouse
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
ClickHouse
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
4df1983d
编写于
12月 07, 2020
作者:
A
alexey-milovidov
提交者:
GitHub
12月 07, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #17571 from vdimir/ip-dict-accept-alias
IP dictionary works with aliased types `IPv4` and `IPv6` (close #6804)
上级
b61feacc
5f330a93
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
12 addition
and
3 deletion
+12
-3
src/Dictionaries/IPAddressDictionary.cpp
src/Dictionaries/IPAddressDictionary.cpp
+6
-3
tests/queries/0_stateless/01018_ip_dictionary.reference
tests/queries/0_stateless/01018_ip_dictionary.reference
+2
-0
tests/queries/0_stateless/01018_ip_dictionary.sql
tests/queries/0_stateless/01018_ip_dictionary.sql
+4
-0
未找到文件。
src/Dictionaries/IPAddressDictionary.cpp
浏览文件 @
4df1983d
...
...
@@ -112,9 +112,12 @@ static void validateKeyTypes(const DataTypes & key_types)
if
(
key_types
.
empty
()
||
key_types
.
size
()
>
2
)
throw
Exception
{
"Expected a single IP address or IP with mask"
,
ErrorCodes
::
TYPE_MISMATCH
};
const
auto
&
actual_type
=
key_types
[
0
]
->
getName
();
if
(
actual_type
!=
"UInt32"
&&
actual_type
!=
"FixedString(16)"
)
throw
Exception
{
"Key does not match, expected either UInt32 or FixedString(16)"
,
ErrorCodes
::
TYPE_MISMATCH
};
const
auto
*
key_ipv4type
=
typeid_cast
<
const
DataTypeUInt32
*>
(
key_types
[
0
].
get
());
const
auto
*
key_ipv6type
=
typeid_cast
<
const
DataTypeFixedString
*>
(
key_types
[
0
].
get
());
if
(
key_ipv4type
==
nullptr
&&
(
key_ipv6type
==
nullptr
||
key_ipv6type
->
getN
()
!=
16
))
throw
Exception
{
"Key does not match, expected either `IPv4` (`UInt32`) or `IPv6` (`FixedString(16)`)"
,
ErrorCodes
::
TYPE_MISMATCH
};
if
(
key_types
.
size
()
>
1
)
{
...
...
tests/queries/0_stateless/01018_ip_dictionary.reference
浏览文件 @
4df1983d
...
...
@@ -50,6 +50,8 @@
1
1
1
1
1
***ipv4 trie dict mask***
1
1
...
...
tests/queries/0_stateless/01018_ip_dictionary.sql
浏览文件 @
4df1983d
...
...
@@ -95,6 +95,10 @@ SELECT 11212 == dictGetUInt32('database_for_dict.dict_ipv4_trie', 'asn', tuple(I
SELECT
11211
==
dictGetUInt32
(
'database_for_dict.dict_ipv4_trie'
,
'asn'
,
tuple
(
IPv4StringToNum
(
'202.79.32.2'
)));
-- check that dictionary works with aliased types `IPv4` and `IPv6`
SELECT
11211
==
dictGetUInt32
(
'database_for_dict.dict_ipv4_trie'
,
'asn'
,
tuple
(
toIPv4
(
'202.79.32.2'
)));
SELECT
11212
==
dictGetUInt32
(
'database_for_dict.dict_ipv4_trie'
,
'asn'
,
tuple
(
toIPv6
(
'::ffff:101.79.55.22'
)));
CREATE
TABLE
database_for_dict
.
table_from_ipv4_trie_dict
(
prefix
String
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录