Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
2e1f293b
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,体验更适合开发者的 AI 搜索 >>
未验证
提交
2e1f293b
编写于
3月 23, 2021
作者:
A
Anton Popov
提交者:
GitHub
3月 23, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #21699 from CurtizJ/fix-map-field-conversion
Fix conversions for fields in function 'arrayElement' for type Map
上级
090e558d
90f91508
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
23 addition
and
13 deletion
+23
-13
src/Functions/array/arrayElement.cpp
src/Functions/array/arrayElement.cpp
+7
-4
tests/queries/0_stateless/01720_type_map_and_casts.reference
tests/queries/0_stateless/01720_type_map_and_casts.reference
+3
-1
tests/queries/0_stateless/01720_type_map_and_casts.sql
tests/queries/0_stateless/01720_type_map_and_casts.sql
+13
-8
未找到文件。
src/Functions/array/arrayElement.cpp
浏览文件 @
2e1f293b
...
...
@@ -872,15 +872,18 @@ bool FunctionArrayElement::matchKeyToIndexNumberConst(
if
(
!
data_numeric
)
return
false
;
bool
is_integer_field
=
Field
::
dispatch
([](
const
auto
&
value
)
std
::
optional
<
DataType
>
index_as_integer
;
Field
::
dispatch
([
&
](
const
auto
&
value
)
{
return
is_integer_v
<
std
::
decay_t
<
decltype
(
value
)
>>
;
using
FieldType
=
std
::
decay_t
<
decltype
(
value
)
>
;
if
constexpr
(
is_integer_v
<
FieldType
>
&&
std
::
is_convertible_v
<
FieldType
,
DataType
>
)
index_as_integer
=
static_cast
<
DataType
>
(
value
);
},
index
);
if
(
!
i
s_integer_field
)
if
(
!
i
ndex_as_integer
)
return
false
;
MatcherNumberConst
<
DataType
>
matcher
{
data_numeric
->
getData
(),
get
<
DataType
>
(
index
)
};
MatcherNumberConst
<
DataType
>
matcher
{
data_numeric
->
getData
(),
*
index_as_integer
};
executeMatchKeyToIndex
(
offsets
,
matched_idxs
,
matcher
);
return
true
;
}
...
...
tests/queries/0_stateless/01720_type_map_and_casts.reference
浏览文件 @
2e1f293b
...
...
@@ -31,10 +31,12 @@ Map(Date, Int32)
Map(UUID, UInt16)
{'00001192-0000-4000-8000-000000000001':1,'00001192-0000-4000-7000-000000000001':2}
0 2 1
Map(Int128,
Int32
)
Map(Int128,
String
)
{-1:'a',0:'b',1234567898765432193024000:'c',-1234567898765432193024000:'d'}
a b c d
a
b
a b c d
b b b b
tests/queries/0_stateless/01720_type_map_and_casts.sql
浏览文件 @
2e1f293b
...
...
@@ -11,7 +11,7 @@ SELECT 'Map(Int8, Int8)';
SELECT
m
FROM
table_map_with_key_integer
;
SELECT
m
[
127
],
m
[
1
],
m
[
0
],
m
[
-
1
]
FROM
table_map_with_key_integer
;
SELECT
m
[
toInt8
(
number
-
2
)]
FROM
table_map_with_key_integer
ARRAY
JOIN
range
(
5
)
AS
number
;
SELECT
m
[
toInt8
(
number
-
2
)]
FROM
table_map_with_key_integer
ARRAY
JOIN
[
0
,
1
,
2
,
3
,
4
]
AS
number
;
SELECT
count
()
FROM
table_map_with_key_integer
WHERE
m
=
map
();
...
...
@@ -26,7 +26,7 @@ SELECT 'Map(Int32, UInt16)';
SELECT
m
FROM
table_map_with_key_integer
;
SELECT
m
[
-
1
],
m
[
2147483647
],
m
[
-
2147483648
]
FROM
table_map_with_key_integer
;
SELECT
m
[
toInt32
(
number
-
2
)]
FROM
table_map_with_key_integer
ARRAY
JOIN
range
(
5
)
AS
number
;
SELECT
m
[
toInt32
(
number
-
2
)]
FROM
table_map_with_key_integer
ARRAY
JOIN
[
0
,
1
,
2
,
3
,
4
]
AS
number
;
DROP
TABLE
IF
EXISTS
table_map_with_key_integer
;
...
...
@@ -39,7 +39,7 @@ SELECT 'Map(Date, Int32)';
SELECT
m
FROM
table_map_with_key_integer
;
SELECT
m
[
toDate
(
'2020-01-01'
)],
m
[
toDate
(
'2020-01-02'
)],
m
[
toDate
(
'2020-01-03'
)]
FROM
table_map_with_key_integer
;
SELECT
m
[
toDate
(
number
)]
FROM
table_map_with_key_integer
ARRAY
JOIN
range
(
3
)
AS
number
;
SELECT
m
[
toDate
(
number
)]
FROM
table_map_with_key_integer
ARRAY
JOIN
[
0
,
1
,
2
]
AS
number
;
DROP
TABLE
IF
EXISTS
table_map_with_key_integer
;
...
...
@@ -51,12 +51,14 @@ INSERT INTO table_map_with_key_integer VALUES ('2020-01-01', map('00001192-0000-
SELECT
'Map(UUID, UInt16)'
;
SELECT
m
FROM
table_map_with_key_integer
;
SELECT
m
[
toUUID
(
'00001192-0000-4000-6000-000000000001'
)],
m
[
toUUID
(
'00001192-0000-4000-7000-000000000001'
)],
SELECT
m
[
toUUID
(
'00001192-0000-4000-6000-000000000001'
)],
m
[
toUUID
(
'00001192-0000-4000-7000-000000000001'
)],
m
[
toUUID
(
'00001192-0000-4000-8000-000000000001'
)]
FROM
table_map_with_key_integer
;
SELECT
m
[
257
],
m
[
1
]
FROM
table_map_with_key_integer
;
-- { serverError 43 }
DROP
TABLE
IF
EXISTS
table_map_with_key_integer
;
CREATE
TABLE
table_map_with_key_integer
(
d
DATE
,
m
Map
(
Int128
,
String
))
...
...
@@ -65,11 +67,14 @@ ENGINE = MergeTree() ORDER BY d;
INSERT
INTO
table_map_with_key_integer
SELECT
'2020-01-01'
,
map
(
-
1
,
'a'
,
0
,
'b'
,
toInt128
(
1234567898765432123456789
),
'c'
,
toInt128
(
-
1234567898765432123456789
),
'd'
);
SELECT
'Map(Int128,
Int32
)'
;
SELECT
'Map(Int128,
String
)'
;
SELECT
m
FROM
table_map_with_key_integer
;
SELECT
m
[
toInt128
(
-
1
)],
m
[
toInt128
(
0
)],
m
[
toInt128
(
1234567898765432123456789
)],
m
[
toInt128
(
-
1234567898765432123456789
)]
FROM
table_map_with_key_integer
;
SELECT
m
[
toInt128
(
number
-
2
)]
FROM
table_map_with_key_integer
ARRAY
JOIN
range
(
4
)
AS
number
;
SELECT
m
[
toInt128
(
number
-
2
)]
FROM
table_map_with_key_integer
ARRAY
JOIN
[
0
,
1
,
2
,
3
]
AS
number
;
SELECT
m
[
-
1
],
m
[
0
],
m
[
toInt128
(
1234567898765432123456789
)],
m
[
toInt128
(
-
1234567898765432123456789
)]
FROM
table_map_with_key_integer
;
SELECT
m
[
toUInt64
(
0
)],
m
[
toInt64
(
0
)],
m
[
toUInt8
(
0
)],
m
[
toUInt16
(
0
)]
FROM
table_map_with_key_integer
;
DROP
TABLE
IF
EXISTS
table_map_with_key_integer
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录