Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
3f678a30
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,发现更多精彩内容 >>
提交
3f678a30
编写于
12月 29, 2016
作者:
A
Alexey Milovidov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Functions: little better [#METR-2944].
上级
32be0083
变更
31
隐藏空白更改
内联
并排
Showing
31 changed file
with
393 addition
and
605 deletion
+393
-605
dbms/include/DB/Functions/FunctionsArithmetic.h
dbms/include/DB/Functions/FunctionsArithmetic.h
+4
-10
dbms/include/DB/Functions/FunctionsArray.h
dbms/include/DB/Functions/FunctionsArray.h
+26
-10
dbms/include/DB/Functions/FunctionsCoding.h
dbms/include/DB/Functions/FunctionsCoding.h
+31
-72
dbms/include/DB/Functions/FunctionsComparison.h
dbms/include/DB/Functions/FunctionsComparison.h
+2
-5
dbms/include/DB/Functions/FunctionsConditional.h
dbms/include/DB/Functions/FunctionsConditional.h
+8
-5
dbms/include/DB/Functions/FunctionsConversion.h
dbms/include/DB/Functions/FunctionsConversion.h
+12
-22
dbms/include/DB/Functions/FunctionsDateTime.h
dbms/include/DB/Functions/FunctionsDateTime.h
+13
-25
dbms/include/DB/Functions/FunctionsDictionaries.h
dbms/include/DB/Functions/FunctionsDictionaries.h
+28
-72
dbms/include/DB/Functions/FunctionsFormatting.h
dbms/include/DB/Functions/FunctionsFormatting.h
+4
-10
dbms/include/DB/Functions/FunctionsGeo.h
dbms/include/DB/Functions/FunctionsGeo.h
+11
-15
dbms/include/DB/Functions/FunctionsHashing.h
dbms/include/DB/Functions/FunctionsHashing.h
+12
-15
dbms/include/DB/Functions/FunctionsHigherOrder.h
dbms/include/DB/Functions/FunctionsHigherOrder.h
+3
-0
dbms/include/DB/Functions/FunctionsLogical.h
dbms/include/DB/Functions/FunctionsLogical.h
+5
-5
dbms/include/DB/Functions/FunctionsMath.h
dbms/include/DB/Functions/FunctionsMath.h
+11
-25
dbms/include/DB/Functions/FunctionsMiscellaneous.h
dbms/include/DB/Functions/FunctionsMiscellaneous.h
+59
-99
dbms/include/DB/Functions/FunctionsNull.h
dbms/include/DB/Functions/FunctionsNull.h
+7
-0
dbms/include/DB/Functions/FunctionsRandom.h
dbms/include/DB/Functions/FunctionsRandom.h
+6
-0
dbms/include/DB/Functions/FunctionsReinterpret.h
dbms/include/DB/Functions/FunctionsReinterpret.h
+4
-10
dbms/include/DB/Functions/FunctionsRound.h
dbms/include/DB/Functions/FunctionsRound.h
+3
-0
dbms/include/DB/Functions/FunctionsString.h
dbms/include/DB/Functions/FunctionsString.h
+11
-15
dbms/include/DB/Functions/FunctionsStringArray.h
dbms/include/DB/Functions/FunctionsStringArray.h
+10
-11
dbms/include/DB/Functions/FunctionsStringSearch.h
dbms/include/DB/Functions/FunctionsStringSearch.h
+6
-15
dbms/include/DB/Functions/FunctionsTransform.h
dbms/include/DB/Functions/FunctionsTransform.h
+3
-0
dbms/include/DB/Functions/FunctionsURL.h
dbms/include/DB/Functions/FunctionsURL.h
+8
-20
dbms/include/DB/Functions/IFunction.h
dbms/include/DB/Functions/IFunction.h
+10
-0
dbms/src/Functions/FunctionsArray.cpp
dbms/src/Functions/FunctionsArray.cpp
+0
-27
dbms/src/Functions/FunctionsCharset.cpp
dbms/src/Functions/FunctionsCharset.cpp
+2
-5
dbms/src/Functions/FunctionsMiscellaneous.cpp
dbms/src/Functions/FunctionsMiscellaneous.cpp
+1
-5
dbms/src/Functions/FunctionsNull.cpp
dbms/src/Functions/FunctionsNull.cpp
+0
-25
dbms/src/Functions/FunctionsString.cpp
dbms/src/Functions/FunctionsString.cpp
+0
-12
dbms/src/Functions/IFunction.cpp
dbms/src/Functions/IFunction.cpp
+93
-70
未找到文件。
dbms/include/DB/Functions/FunctionsArithmetic.h
浏览文件 @
3f678a30
...
...
@@ -670,14 +670,11 @@ public:
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
2
;
}
/// Получить типы результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
2
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 2."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
DataTypePtr
type_res
;
if
(
!
(
checkLeftType
<
DataTypeDate
>
(
arguments
,
type_res
)
...
...
@@ -783,14 +780,11 @@ public:
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
1
;
}
/// Получить типы результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
1
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 1."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
DataTypePtr
result
;
if
(
!
(
checkType
<
DataTypeUInt8
>
(
arguments
,
result
)
...
...
dbms/include/DB/Functions/FunctionsArray.h
浏览文件 @
3f678a30
...
...
@@ -80,6 +80,9 @@ public:
bool
hasSpecialSupportForNulls
()
const
override
{
return
true
;
}
bool
isVariadic
()
const
override
{
return
true
;
}
size_t
getNumberOfArguments
()
const
override
{
return
0
;
}
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
;
...
...
@@ -112,6 +115,8 @@ public:
/// Получить имя функции.
String
getName
()
const
override
;
size_t
getNumberOfArguments
()
const
override
{
return
2
;
}
/// Получить типы результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
;
...
...
@@ -1015,14 +1020,11 @@ public:
return
true
;
}
size_t
getNumberOfArguments
()
const
override
{
return
2
;
}
/// Получить типы результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
2
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 2."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
const
DataTypeArray
*
array_type
=
typeid_cast
<
const
DataTypeArray
*>
(
arguments
[
0
].
get
());
if
(
!
array_type
)
throw
Exception
(
"First argument for function "
+
getName
()
+
" must be an array."
,
...
...
@@ -1189,6 +1191,8 @@ public:
/// Получить имя функции.
String
getName
()
const
override
;
size_t
getNumberOfArguments
()
const
override
{
return
2
;
}
/// Получить типы результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
;
...
...
@@ -1208,6 +1212,9 @@ public:
/// Получить имя функции.
String
getName
()
const
override
;
bool
isVariadic
()
const
override
{
return
true
;
}
size_t
getNumberOfArguments
()
const
override
{
return
0
;
}
/// Получить типы результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
;
...
...
@@ -1248,6 +1255,9 @@ public:
/// Получить имя функции.
String
getName
()
const
override
;
bool
isVariadic
()
const
override
{
return
true
;
}
size_t
getNumberOfArguments
()
const
override
{
return
0
;
}
/// Получить типы результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
;
...
...
@@ -1299,13 +1309,10 @@ private:
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
0
;
}
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
0
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 0."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
return
std
::
make_shared
<
DataTypeArray
>
(
std
::
make_shared
<
DataType
>
());
}
...
...
@@ -1332,6 +1339,8 @@ public:
private:
String
getName
()
const
override
;
size_t
getNumberOfArguments
()
const
override
{
return
1
;
}
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
;
template
<
typename
T
>
...
...
@@ -1350,6 +1359,8 @@ public:
/// Получить имя функции.
String
getName
()
const
override
;
size_t
getNumberOfArguments
()
const
override
{
return
1
;
}
/// Получить типы результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
;
...
...
@@ -1389,6 +1400,8 @@ public:
/// Получить имя функции.
String
getName
()
const
override
;
size_t
getNumberOfArguments
()
const
override
{
return
1
;
}
/// Получить типы результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
;
...
...
@@ -1431,6 +1444,9 @@ public:
/// Получить имя функции.
String
getName
()
const
override
;
bool
isVariadic
()
const
override
{
return
true
;
}
size_t
getNumberOfArguments
()
const
override
{
return
0
;
}
void
getReturnTypeAndPrerequisitesImpl
(
const
ColumnsWithTypeAndName
&
arguments
,
DataTypePtr
&
out_return_type
,
...
...
dbms/include/DB/Functions/FunctionsCoding.h
浏览文件 @
3f678a30
...
...
@@ -179,13 +179,10 @@ public:
String
getName
()
const
override
{
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
1
;
}
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
1
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 1."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
const
auto
ptr
=
typeid_cast
<
const
DataTypeFixedString
*>
(
arguments
[
0
].
get
());
if
(
!
ptr
||
ptr
->
getN
()
!=
ipv6_bytes_length
)
throw
Exception
(
"Illegal type "
+
arguments
[
0
]
->
getName
()
+
...
...
@@ -266,13 +263,10 @@ public:
String
getName
()
const
override
{
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
3
;
}
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
3
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 3."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
const
auto
ptr
=
typeid_cast
<
const
DataTypeFixedString
*>
(
arguments
[
0
].
get
());
if
(
!
ptr
||
ptr
->
getN
()
!=
ipv6_bytes_length
)
throw
Exception
(
"Illegal type "
+
arguments
[
0
]
->
getName
()
+
...
...
@@ -433,13 +427,10 @@ public:
String
getName
()
const
override
{
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
1
;
}
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
1
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 1."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
if
(
!
typeid_cast
<
const
DataTypeString
*>
(
&*
arguments
[
0
]))
throw
Exception
(
"Illegal type "
+
arguments
[
0
]
->
getName
()
+
" of argument of function "
+
getName
(),
ErrorCodes
::
ILLEGAL_TYPE_OF_ARGUMENT
);
...
...
@@ -652,14 +643,11 @@ public:
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
1
;
}
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
1
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 1."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
if
(
!
typeid_cast
<
const
DataTypeUInt32
*>
(
&*
arguments
[
0
]))
throw
Exception
(
"Illegal type "
+
arguments
[
0
]
->
getName
()
+
" of argument of function "
+
getName
()
+
", expected UInt32"
,
ErrorCodes
::
ILLEGAL_TYPE_OF_ARGUMENT
);
...
...
@@ -758,14 +746,11 @@ public:
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
1
;
}
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
1
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 1."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
if
(
!
typeid_cast
<
const
DataTypeString
*>
(
&*
arguments
[
0
]))
throw
Exception
(
"Illegal type "
+
arguments
[
0
]
->
getName
()
+
" of argument of function "
+
getName
(),
ErrorCodes
::
ILLEGAL_TYPE_OF_ARGUMENT
);
...
...
@@ -844,14 +829,11 @@ public:
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
1
;
}
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
1
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 1."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
if
(
!
typeid_cast
<
const
DataTypeUInt32
*>
(
&*
arguments
[
0
]))
throw
Exception
(
"Illegal type "
+
arguments
[
0
]
->
getName
()
+
" of argument of function "
+
getName
()
+
", expected UInt32"
,
ErrorCodes
::
ILLEGAL_TYPE_OF_ARGUMENT
);
...
...
@@ -949,13 +931,10 @@ public:
String
getName
()
const
override
{
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
1
;
}
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
1
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 1."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
if
(
typeid_cast
<
const
DataTypeUInt32
*>
(
arguments
[
0
].
get
())
==
nullptr
)
throw
Exception
(
"Illegal type "
+
arguments
[
0
]
->
getName
()
+
" of argument of function "
+
getName
(),
ErrorCodes
::
ILLEGAL_TYPE_OF_ARGUMENT
);
...
...
@@ -1062,13 +1041,10 @@ public:
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
1
;
}
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
1
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 1."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
const
auto
ptr
=
typeid_cast
<
const
DataTypeFixedString
*>
(
arguments
[
0
].
get
());
if
(
!
ptr
||
ptr
->
getN
()
!=
uuid_bytes_length
)
throw
Exception
(
"Illegal type "
+
arguments
[
0
]
->
getName
()
+
...
...
@@ -1176,13 +1152,10 @@ public:
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
1
;
}
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
1
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 1."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
/// String or FixedString(36)
if
(
!
typeid_cast
<
const
DataTypeString
*>
(
arguments
[
0
].
get
()))
{
...
...
@@ -1298,14 +1271,11 @@ public:
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
1
;
}
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
1
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 1."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
if
(
!
typeid_cast
<
const
DataTypeString
*>
(
&*
arguments
[
0
])
&&
!
typeid_cast
<
const
DataTypeFixedString
*>
(
&*
arguments
[
0
])
&&
!
typeid_cast
<
const
DataTypeDate
*>
(
&*
arguments
[
0
])
&&
...
...
@@ -1546,14 +1516,11 @@ public:
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
1
;
}
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
1
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 1."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
if
(
!
typeid_cast
<
const
DataTypeString
*>
(
&*
arguments
[
0
]))
throw
Exception
(
"Illegal type "
+
arguments
[
0
]
->
getName
()
+
" of argument of function "
+
getName
(),
ErrorCodes
::
ILLEGAL_TYPE_OF_ARGUMENT
);
...
...
@@ -1654,14 +1621,11 @@ public:
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
1
;
}
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
1
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 1."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
if
(
!
typeid_cast
<
const
DataTypeUInt8
*>
(
&*
arguments
[
0
])
&&
!
typeid_cast
<
const
DataTypeUInt16
*>
(
&*
arguments
[
0
])
&&
!
typeid_cast
<
const
DataTypeUInt32
*>
(
&*
arguments
[
0
])
&&
...
...
@@ -1767,14 +1731,11 @@ public:
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
1
;
}
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
1
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 1."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
if
(
!
typeid_cast
<
const
DataTypeFixedString
*>
(
&*
arguments
[
0
])
&&
!
typeid_cast
<
const
DataTypeString
*>
(
&*
arguments
[
0
]))
throw
Exception
(
"Illegal type "
+
arguments
[
0
]
->
getName
()
+
" of argument of function "
+
getName
(),
...
...
@@ -1911,15 +1872,10 @@ public:
String
getName
()
const
override
{
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
2
;
}
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
2
)
throw
Exception
{
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 2."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
};
const
auto
first_arg
=
arguments
.
front
().
get
();
if
(
!
typeid_cast
<
const
DataTypeUInt8
*>
(
first_arg
)
&&
!
typeid_cast
<
const
DataTypeUInt16
*>
(
first_arg
)
&&
...
...
@@ -2092,6 +2048,9 @@ public:
String
getName
()
const
override
{
return
name
;
}
bool
isVariadic
()
const
override
{
return
true
;
}
size_t
getNumberOfArguments
()
const
override
{
return
0
;
}
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
<
2
)
...
...
dbms/include/DB/Functions/FunctionsComparison.h
浏览文件 @
3f678a30
...
...
@@ -784,14 +784,11 @@ public:
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
2
;
}
/// Получить типы результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
2
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 2."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
bool
left_is_date
=
false
;
bool
left_is_date_time
=
false
;
bool
left_is_enum8
=
false
;
...
...
dbms/include/DB/Functions/FunctionsConditional.h
浏览文件 @
3f678a30
...
...
@@ -1318,14 +1318,11 @@ public:
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
3
;
}
/// Получить типы результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
3
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 3."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
if
(
!
typeid_cast
<
const
DataTypeUInt8
*>
(
&*
arguments
[
0
]))
throw
Exception
(
"Illegal type of first argument (condition) of function if. Must be UInt8."
,
ErrorCodes
::
ILLEGAL_TYPE_OF_ARGUMENT
);
...
...
@@ -1486,6 +1483,8 @@ public:
public:
String
getName
()
const
override
;
bool
isVariadic
()
const
override
{
return
true
;
}
size_t
getNumberOfArguments
()
const
override
{
return
0
;
}
bool
hasSpecialSupportForNulls
()
const
override
;
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
args
)
const
override
;
void
executeImpl
(
Block
&
block
,
const
ColumnNumbers
&
args
,
size_t
result
)
override
;
...
...
@@ -1515,6 +1514,8 @@ public:
public:
FunctionCaseWithExpr
(
const
Context
&
context_
);
bool
isVariadic
()
const
override
{
return
true
;
}
size_t
getNumberOfArguments
()
const
override
{
return
0
;
}
String
getName
()
const
override
;
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
args
)
const
override
;
void
executeImpl
(
Block
&
block
,
const
ColumnNumbers
&
args
,
size_t
result
)
override
;
...
...
@@ -1533,6 +1534,8 @@ public:
public:
String
getName
()
const
override
;
bool
isVariadic
()
const
override
{
return
true
;
}
size_t
getNumberOfArguments
()
const
override
{
return
0
;
}
bool
hasSpecialSupportForNulls
()
const
override
;
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
args
)
const
override
;
void
executeImpl
(
Block
&
block
,
const
ColumnNumbers
&
args
,
size_t
result
)
override
;
...
...
dbms/include/DB/Functions/FunctionsConversion.h
浏览文件 @
3f678a30
...
...
@@ -1305,6 +1305,9 @@ public:
return
name
;
}
bool
isVariadic
()
const
override
{
return
true
;
}
size_t
getNumberOfArguments
()
const
override
{
return
0
;
}
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
...
...
@@ -1497,32 +1500,24 @@ public:
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
1
;
}
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
return
getReturnTypeInternal
(
arguments
);
return
std
::
make_shared
<
ToDataType
>
(
);
}
void
executeImpl
(
Block
&
block
,
const
ColumnNumbers
&
arguments
,
size_t
result
)
override
{
IDataType
*
from_type
=
block
.
getByPosition
(
arguments
[
0
]).
type
.
get
();
if
(
typeid_cast
<
const
DataTypeString
*>
(
from_type
))
ConvertOrZeroImpl
<
ToDataType
,
Name
>::
execute
(
block
,
arguments
,
result
);
if
(
typeid_cast
<
const
DataTypeString
*>
(
from_type
))
ConvertOrZeroImpl
<
ToDataType
,
Name
>::
execute
(
block
,
arguments
,
result
);
else
throw
Exception
(
"Illegal type "
+
block
.
getByPosition
(
arguments
[
0
]).
type
->
getName
()
+
" of argument of function "
+
getName
()
+
". Only String argument is accepted for try-conversion function. For other arguments, use function without 'try'."
,
ErrorCodes
::
ILLEGAL_TYPE_OF_ARGUMENT
);
}
private:
DataTypePtr
getReturnTypeInternal
(
const
DataTypes
&
arguments
)
const
{
if
(
arguments
.
size
()
!=
1
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 1."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
return
std
::
make_shared
<
ToDataType
>
();
}
};
...
...
@@ -1540,6 +1535,8 @@ public:
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
2
;
}
/** Получить тип результата по типам аргументов и значениям константных аргументов.
* Если функция неприменима для данных аргументов - кинуть исключение.
* Для неконстантных столбцов arguments[i].column = nullptr.
...
...
@@ -1548,10 +1545,6 @@ public:
DataTypePtr
&
out_return_type
,
std
::
vector
<
ExpressionAction
>
&
out_prerequisites
)
override
{
if
(
arguments
.
size
()
!=
2
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 2."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
if
(
!
arguments
[
1
].
column
)
throw
Exception
(
"Second argument for function "
+
getName
()
+
" must be constant"
,
ErrorCodes
::
ILLEGAL_COLUMN
);
if
(
!
typeid_cast
<
const
DataTypeString
*>
(
arguments
[
0
].
type
.
get
())
&&
...
...
@@ -2329,15 +2322,12 @@ public:
bool
hasSpecialSupportForNulls
()
const
override
{
return
true
;
}
size_t
getNumberOfArguments
()
const
override
{
return
2
;
}
void
getReturnTypeAndPrerequisitesImpl
(
const
ColumnsWithTypeAndName
&
arguments
,
DataTypePtr
&
out_return_type
,
std
::
vector
<
ExpressionAction
>
&
out_prerequisites
)
override
{
if
(
arguments
.
size
()
!=
2
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 2."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
const
auto
type_col
=
typeid_cast
<
const
ColumnConstString
*>
(
arguments
.
back
().
column
.
get
());
if
(
!
type_col
)
throw
Exception
(
"Second argument to "
+
getName
()
+
" must be a constant string describing type"
,
...
...
dbms/include/DB/Functions/FunctionsDateTime.h
浏览文件 @
3f678a30
...
...
@@ -629,6 +629,9 @@ public:
return
name
;
}
bool
isVariadic
()
const
override
{
return
true
;
}
size_t
getNumberOfArguments
()
const
override
{
return
0
;
}
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
...
...
@@ -727,14 +730,11 @@ public:
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
0
;
}
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
0
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 0."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
return
std
::
make_shared
<
DataTypeDateTime
>
();
}
...
...
@@ -760,14 +760,11 @@ public:
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
0
;
}
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
0
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 0."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
return
std
::
make_shared
<
DataTypeDate
>
();
}
...
...
@@ -793,14 +790,11 @@ public:
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
0
;
}
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
0
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 0."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
return
std
::
make_shared
<
DataTypeDate
>
();
}
...
...
@@ -826,14 +820,11 @@ public:
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
1
;
}
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
1
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 1."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
if
(
!
typeid_cast
<
const
DataTypeDateTime
*>
(
&*
arguments
[
0
]))
throw
Exception
(
"Illegal type "
+
arguments
[
0
]
->
getName
()
+
" of first argument of function "
+
getName
()
+
". Must be DateTime."
,
ErrorCodes
::
ILLEGAL_TYPE_OF_ARGUMENT
);
...
...
@@ -962,14 +953,11 @@ public:
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
2
;
}
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
2
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 2."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
if
(
!
typeid_cast
<
const
DataTypeDateTime
*>
(
&*
arguments
[
0
]))
throw
Exception
(
"Illegal type "
+
arguments
[
0
]
->
getName
()
+
" of first argument of function "
+
getName
()
+
". Must be DateTime."
,
ErrorCodes
::
ILLEGAL_TYPE_OF_ARGUMENT
);
...
...
dbms/include/DB/Functions/FunctionsDictionaries.h
浏览文件 @
3f678a30
...
...
@@ -203,6 +203,9 @@ public:
return
name
;
}
bool
isVariadic
()
const
override
{
return
true
;
}
size_t
getNumberOfArguments
()
const
override
{
return
0
;
}
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
...
...
@@ -296,6 +299,9 @@ public:
return
name
;
}
bool
isVariadic
()
const
override
{
return
true
;
}
size_t
getNumberOfArguments
()
const
override
{
return
0
;
}
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
...
...
@@ -429,6 +435,9 @@ public:
return
name
;
}
bool
isVariadic
()
const
override
{
return
true
;
}
size_t
getNumberOfArguments
()
const
override
{
return
0
;
}
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
...
...
@@ -702,6 +711,9 @@ public:
return
name
;
}
bool
isVariadic
()
const
override
{
return
true
;
}
size_t
getNumberOfArguments
()
const
override
{
return
0
;
}
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
...
...
@@ -784,14 +796,10 @@ public:
String
getName
()
const
override
{
return
name
;
}
private:
size_t
getNumberOfArguments
()
const
override
{
return
2
;
}
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
2
)
throw
Exception
{
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 2."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
};
if
(
!
typeid_cast
<
const
DataTypeString
*>
(
arguments
[
0
].
get
()))
throw
Exception
{
"Illegal type "
+
arguments
[
0
]
->
getName
()
+
" of first argument of function "
+
getName
()
...
...
@@ -837,12 +845,6 @@ private:
if
(
!
dict
)
return
false
;
if
(
arguments
.
size
()
!=
2
)
throw
Exception
{
"Function "
+
getName
()
+
" for dictionary of type "
+
dict
->
getTypeName
()
+
" requires exactly 2 arguments"
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
};
const
auto
id_col_untyped
=
block
.
getByPosition
(
arguments
[
1
]).
column
.
get
();
if
(
const
auto
id_col
=
typeid_cast
<
const
ColumnUInt64
*>
(
id_col_untyped
))
{
...
...
@@ -878,12 +880,6 @@ private:
if
(
!
dict
)
return
false
;
if
(
arguments
.
size
()
!=
2
)
throw
Exception
{
"Function "
+
getName
()
+
" for dictionary of type "
+
dict
->
getTypeName
()
+
" requires exactly 2 arguments"
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
};
const
auto
key_col_with_type
=
block
.
getByPosition
(
arguments
[
1
]);
if
(
typeid_cast
<
const
ColumnTuple
*>
(
key_col_with_type
.
column
.
get
())
||
typeid_cast
<
const
ColumnConstTuple
*>
(
key_col_with_type
.
column
.
get
()))
...
...
@@ -929,6 +925,9 @@ public:
String
getName
()
const
override
{
return
name
;
}
private:
bool
isVariadic
()
const
override
{
return
true
;
}
size_t
getNumberOfArguments
()
const
override
{
return
0
;
}
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
3
&&
arguments
.
size
()
!=
4
)
...
...
@@ -1206,14 +1205,10 @@ public:
String
getName
()
const
override
{
return
name
;
}
private:
size_t
getNumberOfArguments
()
const
override
{
return
4
;
}
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
4
)
throw
Exception
{
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 4."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
};
if
(
!
typeid_cast
<
const
DataTypeString
*>
(
arguments
[
0
].
get
()))
throw
Exception
{
"Illegal type "
+
arguments
[
0
]
->
getName
()
+
" of first argument of function "
+
getName
()
+
...
...
@@ -1273,12 +1268,6 @@ private:
if
(
!
dict
)
return
false
;
if
(
arguments
.
size
()
!=
4
)
throw
Exception
{
"Function "
+
getName
()
+
" for dictionary of type "
+
dict
->
getTypeName
()
+
" requires exactly 4 arguments"
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
};
const
auto
attr_name_col
=
typeid_cast
<
const
ColumnConst
<
String
>
*>
(
block
.
getByPosition
(
arguments
[
1
]).
column
.
get
());
if
(
!
attr_name_col
)
throw
Exception
{
...
...
@@ -1378,12 +1367,6 @@ private:
if
(
!
dict
)
return
false
;
if
(
arguments
.
size
()
!=
4
)
throw
Exception
{
"Function "
+
getName
()
+
" for dictionary of type "
+
dict
->
getTypeName
()
+
" requires exactly 4 arguments"
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
};
const
auto
attr_name_col
=
typeid_cast
<
const
ColumnConst
<
String
>
*>
(
block
.
getByPosition
(
arguments
[
1
]).
column
.
get
());
if
(
!
attr_name_col
)
throw
Exception
{
...
...
@@ -1499,14 +1482,11 @@ public:
String
getName
()
const
override
{
return
name
;
}
private:
bool
isVariadic
()
const
override
{
return
true
;
}
size_t
getNumberOfArguments
()
const
override
{
return
0
;
}
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
3
&&
arguments
.
size
()
!=
4
)
throw
Exception
{
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 3 or 4."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
};
if
(
!
typeid_cast
<
const
DataTypeString
*>
(
arguments
[
0
].
get
()))
{
throw
Exception
{
...
...
@@ -1813,14 +1793,10 @@ public:
String
getName
()
const
override
{
return
name
;
}
private:
size_t
getNumberOfArguments
()
const
override
{
return
4
;
}
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
4
)
throw
Exception
{
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 4."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
};
if
(
!
typeid_cast
<
const
DataTypeString
*>
(
arguments
[
0
].
get
()))
{
throw
Exception
{
...
...
@@ -1886,12 +1862,6 @@ private:
if
(
!
dict
)
return
false
;
if
(
arguments
.
size
()
!=
4
)
throw
Exception
{
"Function "
+
getName
()
+
" for dictionary of type "
+
dict
->
getTypeName
()
+
" requires exactly 4 arguments."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
};
const
auto
attr_name_col
=
typeid_cast
<
const
ColumnConst
<
String
>
*>
(
block
.
getByPosition
(
arguments
[
1
]).
column
.
get
());
if
(
!
attr_name_col
)
throw
Exception
{
...
...
@@ -1996,12 +1966,6 @@ private:
if
(
!
dict
)
return
false
;
if
(
arguments
.
size
()
!=
4
)
throw
Exception
{
"Function "
+
getName
()
+
" for dictionary of type "
+
dict
->
getTypeName
()
+
" requires exactly 4 arguments"
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
};
const
auto
attr_name_col
=
typeid_cast
<
const
ColumnConst
<
String
>
*>
(
block
.
getByPosition
(
arguments
[
1
]).
column
.
get
());
if
(
!
attr_name_col
)
throw
Exception
{
...
...
@@ -2084,14 +2048,10 @@ public:
String
getName
()
const
override
{
return
name
;
}
private:
size_t
getNumberOfArguments
()
const
override
{
return
2
;
}
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
2
)
throw
Exception
{
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 2."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
};
if
(
!
typeid_cast
<
const
DataTypeString
*>
(
arguments
[
0
].
get
()))
{
throw
Exception
{
...
...
@@ -2247,14 +2207,10 @@ public:
String
getName
()
const
override
{
return
name
;
}
private:
size_t
getNumberOfArguments
()
const
override
{
return
3
;
}
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
3
)
throw
Exception
{
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 3."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
};
if
(
!
typeid_cast
<
const
DataTypeString
*>
(
arguments
[
0
].
get
()))
{
throw
Exception
{
...
...
dbms/include/DB/Functions/FunctionsFormatting.h
浏览文件 @
3f678a30
...
...
@@ -30,14 +30,11 @@ public:
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
1
;
}
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
virtual
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
1
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 1."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
const
IDataType
*
type
=
&*
arguments
[
0
];
if
(
!
typeid_cast
<
const
DataTypeUInt8
*>
(
type
)
&&
...
...
@@ -143,14 +140,11 @@ public:
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
1
;
}
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
virtual
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
1
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 1."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
const
IDataType
&
type
=
*
arguments
[
0
];
if
(
!
type
.
behavesAsNumber
())
...
...
dbms/include/DB/Functions/FunctionsGeo.h
浏览文件 @
3f678a30
...
...
@@ -20,21 +20,21 @@ const Float64 EARTH_RADIUS_IN_METERS = 6372797.560856;
static
inline
Float64
degToRad
(
Float64
angle
)
{
return
angle
*
DEGREES_IN_RADIANS
;
}
static
inline
Float64
radToDeg
(
Float64
angle
)
{
return
angle
/
DEGREES_IN_RADIANS
;
}
/**
* The function calculates distance in meters between two points on Earth specified by longitude and latitude in degrees.
* The function uses great circle distance formula https://en.wikipedia.org/wiki/Great-circle_distance.
* Throws exception when one or several input values are not within reasonable bounds.
* The function uses great circle distance formula https://en.wikipedia.org/wiki/Great-circle_distance.
* Throws exception when one or several input values are not within reasonable bounds.
* Latitude must be in [-90, 90], longitude must be [-180, 180]
*
*
*/
class
FunctionGreatCircleDistance
:
public
IFunction
{
public:
static
constexpr
auto
name
=
"greatCircleDistance"
;
static
FunctionPtr
create
(
const
Context
&
)
{
return
std
::
make_shared
<
FunctionGreatCircleDistance
>
();
}
private:
enum
class
instr_type
:
uint8_t
...
...
@@ -48,14 +48,10 @@ private:
String
getName
()
const
override
{
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
4
;
}
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
4
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
"doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 4"
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
for
(
const
auto
arg_idx
:
ext
::
range
(
0
,
arguments
.
size
()))
{
const
auto
arg
=
arguments
[
arg_idx
].
get
();
...
...
@@ -94,7 +90,7 @@ private:
return
result
;
}
/// https://en.wikipedia.org/wiki/Great-circle_distance
/// https://en.wikipedia.org/wiki/Great-circle_distance
Float64
greatCircleDistance
(
Float64
lon1Deg
,
Float64
lat1Deg
,
Float64
lon2Deg
,
Float64
lat2Deg
)
{
if
(
lon1Deg
<
-
180
||
lon1Deg
>
180
||
...
...
@@ -132,7 +128,7 @@ private:
Float64
res
=
greatCircleDistance
(
colLon1
,
colLat1
,
colLon2
,
colLat2
);
block
.
getByPosition
(
result
).
column
=
std
::
make_shared
<
ColumnConst
<
Float64
>>
(
size
,
res
);
}
else
else
{
const
auto
dst
=
std
::
make_shared
<
ColumnVector
<
Float64
>>
();
block
.
getByPosition
(
result
).
column
=
dst
;
...
...
@@ -147,7 +143,7 @@ private:
vals
[
idx
]
=
static_cast
<
const
ColumnVector
<
Float64
>
*>
(
instrs
[
idx
].
second
)
->
getData
()[
row
];
else
if
(
instr_type
::
get_const_float_64
==
instrs
[
idx
].
first
)
vals
[
idx
]
=
static_cast
<
const
ColumnConst
<
Float64
>
*>
(
instrs
[
idx
].
second
)
->
getData
();
else
else
throw
std
::
logic_error
{
"unknown instr_type"
};
}
dst_data
[
row
]
=
greatCircleDistance
(
vals
[
0
],
vals
[
1
],
vals
[
2
],
vals
[
3
]);
...
...
dbms/include/DB/Functions/FunctionsHashing.h
浏览文件 @
3f678a30
...
...
@@ -179,14 +179,11 @@ public:
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
1
;
}
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
1
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 1."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
if
(
!
typeid_cast
<
const
DataTypeString
*>
(
&*
arguments
[
0
]))
throw
Exception
(
"Illegal type "
+
arguments
[
0
]
->
getName
()
+
" of argument of function "
+
getName
(),
ErrorCodes
::
ILLEGAL_TYPE_OF_ARGUMENT
);
...
...
@@ -240,14 +237,11 @@ public:
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
1
;
}
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
1
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 1."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
if
(
!
typeid_cast
<
const
DataTypeString
*>
(
&*
arguments
[
0
]))
throw
Exception
(
"Illegal type "
+
arguments
[
0
]
->
getName
()
+
" of argument of function "
+
getName
(),
ErrorCodes
::
ILLEGAL_TYPE_OF_ARGUMENT
);
...
...
@@ -338,14 +332,11 @@ public:
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
1
;
}
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
1
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 1."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
if
(
!
arguments
[
0
]
->
isNumeric
())
throw
Exception
(
"Illegal type "
+
arguments
[
0
]
->
getName
()
+
" of argument of function "
+
getName
(),
ErrorCodes
::
ILLEGAL_TYPE_OF_ARGUMENT
);
...
...
@@ -594,6 +585,9 @@ public:
return
name
;
}
bool
isVariadic
()
const
override
{
return
true
;
}
size_t
getNumberOfArguments
()
const
override
{
return
0
;
}
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
...
...
@@ -708,6 +702,9 @@ public:
String
getName
()
const
override
{
return
name
;
}
bool
isVariadic
()
const
override
{
return
true
;
}
size_t
getNumberOfArguments
()
const
override
{
return
0
;
}
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
const
auto
arg_count
=
arguments
.
size
();
...
...
dbms/include/DB/Functions/FunctionsHigherOrder.h
浏览文件 @
3f678a30
...
...
@@ -607,6 +607,9 @@ public:
return
name
;
}
bool
isVariadic
()
const
override
{
return
true
;
}
size_t
getNumberOfArguments
()
const
override
{
return
0
;
}
/// Вызывается, если хоть один агрумент функции - лямбда-выражение.
/// Для аргументов-лямбда-выражений определяет типы аргументов этих выражений.
void
getLambdaArgumentTypesImpl
(
DataTypes
&
arguments
)
const
override
...
...
dbms/include/DB/Functions/FunctionsLogical.h
浏览文件 @
3f678a30
...
...
@@ -247,6 +247,9 @@ public:
return
name
;
}
bool
isVariadic
()
const
override
{
return
true
;
}
size_t
getNumberOfArguments
()
const
override
{
return
0
;
}
/// Получить типы результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
...
...
@@ -401,14 +404,11 @@ public:
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
1
;
}
/// Получить типы результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
1
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 1."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
if
(
!
arguments
[
0
]
->
isNumeric
())
throw
Exception
(
"Illegal type ("
+
arguments
[
0
]
->
getName
()
...
...
dbms/include/DB/Functions/FunctionsMath.h
浏览文件 @
3f678a30
...
...
@@ -24,15 +24,10 @@ public:
private:
String
getName
()
const
override
{
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
0
;
}
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
0
)
throw
Exception
{
"Number of arguments for function "
+
getName
()
+
"doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 0"
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
};
return
std
::
make_shared
<
DataTypeFloat64
>
();
}
...
...
@@ -45,7 +40,8 @@ private:
};
template
<
typename
Impl
>
class
FunctionMathUnaryFloat64
:
public
IFunction
template
<
typename
Impl
>
class
FunctionMathUnaryFloat64
:
public
IFunction
{
public:
static
constexpr
auto
name
=
Impl
::
name
;
...
...
@@ -55,15 +51,10 @@ public:
private:
String
getName
()
const
override
{
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
1
;
}
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
1
)
throw
Exception
{
"Number of arguments for function "
+
getName
()
+
"doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 1"
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
};
const
auto
check_argument_type
=
[
this
]
(
const
IDataType
*
const
arg
)
{
if
(
!
typeid_cast
<
const
DataTypeUInt8
*>
(
arg
)
&&
!
typeid_cast
<
const
DataTypeUInt16
*>
(
arg
)
&&
...
...
@@ -196,7 +187,8 @@ struct UnaryFunctionVectorized
#endif
template
<
typename
Impl
>
class
FunctionMathBinaryFloat64
:
public
IFunction
template
<
typename
Impl
>
class
FunctionMathBinaryFloat64
:
public
IFunction
{
public:
static
constexpr
auto
name
=
Impl
::
name
;
...
...
@@ -206,15 +198,10 @@ public:
private:
String
getName
()
const
override
{
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
2
;
}
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
2
)
throw
Exception
{
"Number of arguments for function "
+
getName
()
+
"doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 2"
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
};
const
auto
check_argument_type
=
[
this
]
(
const
IDataType
*
const
arg
)
{
if
(
!
typeid_cast
<
const
DataTypeUInt8
*>
(
arg
)
&&
!
typeid_cast
<
const
DataTypeUInt16
*>
(
arg
)
&&
...
...
@@ -229,8 +216,7 @@ private:
{
throw
Exception
{
"Illegal type "
+
arg
->
getName
()
+
" of argument of function "
+
getName
(),
ErrorCodes
::
ILLEGAL_TYPE_OF_ARGUMENT
};
ErrorCodes
::
ILLEGAL_TYPE_OF_ARGUMENT
};
}
};
...
...
dbms/include/DB/Functions/FunctionsMiscellaneous.h
浏览文件 @
3f678a30
...
...
@@ -107,13 +107,10 @@ public:
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
0
;
}
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
0
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 0."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
return
std
::
make_shared
<
DataTypeString
>
();
}
...
...
@@ -137,14 +134,11 @@ public:
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
0
;
}
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
0
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 0."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
return
std
::
make_shared
<
DataTypeString
>
();
}
...
...
@@ -177,14 +171,11 @@ public:
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
1
;
}
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
1
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 1."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
return
std
::
make_shared
<
DataTypeUInt64
>
();
}
...
...
@@ -209,14 +200,11 @@ public:
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
1
;
}
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
1
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 1."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
return
std
::
make_shared
<
DataTypeString
>
();
}
...
...
@@ -241,13 +229,10 @@ public:
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
1
;
}
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
1
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 1."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
return
std
::
make_shared
<
DataTypeString
>
();
}
...
...
@@ -271,14 +256,11 @@ public:
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
0
;
}
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
!
arguments
.
empty
())
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 0."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
return
std
::
make_shared
<
DataTypeUInt64
>
();
}
...
...
@@ -303,14 +285,11 @@ public:
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
0
;
}
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
!
arguments
.
empty
())
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 0."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
return
std
::
make_shared
<
DataTypeUInt64
>
();
}
...
...
@@ -345,14 +324,11 @@ public:
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
0
;
}
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
!
arguments
.
empty
())
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 0."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
return
std
::
make_shared
<
DataTypeUInt64
>
();
}
...
...
@@ -381,14 +357,11 @@ public:
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
0
;
}
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
!
arguments
.
empty
())
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 0."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
return
std
::
make_shared
<
DataTypeUInt64
>
();
}
...
...
@@ -421,14 +394,11 @@ public:
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
1
;
}
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
1
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 1."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
if
(
!
typeid_cast
<
const
DataTypeFloat64
*>
(
&*
arguments
[
0
])
&&
!
typeid_cast
<
const
DataTypeFloat32
*>
(
&*
arguments
[
0
])
&&
!
typeid_cast
<
const
DataTypeUInt64
*>
(
&*
arguments
[
0
])
&&
...
...
@@ -491,14 +461,11 @@ public:
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
1
;
}
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
1
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 1."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
return
arguments
[
0
];
}
...
...
@@ -531,14 +498,11 @@ public:
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
2
;
}
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
2
)
throw
Exception
(
"Number of arguments for function '"
+
getName
()
+
"' doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 2."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
return
std
::
make_shared
<
DataTypeUInt8
>
();
}
...
...
@@ -581,6 +545,9 @@ public:
return
name
;
}
bool
isVariadic
()
const
override
{
return
true
;
}
size_t
getNumberOfArguments
()
const
override
{
return
0
;
}
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
...
...
@@ -649,14 +616,12 @@ public:
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
2
;
}
void
getReturnTypeAndPrerequisitesImpl
(
const
ColumnsWithTypeAndName
&
arguments
,
DataTypePtr
&
out_return_type
,
ExpressionActions
::
Actions
&
out_prerequisites
)
override
{
if
(
arguments
.
size
()
!=
2
)
throw
Exception
(
"Function "
+
getName
()
+
" requires exactly two arguments: tuple and element index."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
const
ColumnConstUInt8
*
index_col
=
typeid_cast
<
const
ColumnConstUInt8
*>
(
&*
arguments
[
1
].
column
);
if
(
!
index_col
)
throw
Exception
(
"Second argument to "
+
getName
()
+
" must be a constant UInt8"
,
ErrorCodes
::
ILLEGAL_TYPE_OF_ARGUMENT
);
...
...
@@ -720,6 +685,9 @@ public:
static
constexpr
auto
name
=
"ignore"
;
static
FunctionPtr
create
(
const
Context
&
context
)
{
return
std
::
make_shared
<
FunctionIgnore
>
();
}
bool
isVariadic
()
const
override
{
return
true
;
}
size_t
getNumberOfArguments
()
const
override
{
return
0
;
}
String
getName
()
const
override
{
return
name
;
}
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
return
std
::
make_shared
<
DataTypeUInt8
>
();
}
...
...
@@ -749,6 +717,9 @@ public:
static
constexpr
auto
name
=
"indexHint"
;
static
FunctionPtr
create
(
const
Context
&
context
)
{
return
std
::
make_shared
<
FunctionIndexHint
>
();
}
bool
isVariadic
()
const
override
{
return
true
;
}
size_t
getNumberOfArguments
()
const
override
{
return
0
;
}
String
getName
()
const
override
{
return
name
;
}
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
return
std
::
make_shared
<
DataTypeUInt8
>
();
}
...
...
@@ -772,13 +743,11 @@ public:
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
1
;
}
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
1
)
throw
Exception
(
"Function "
+
getName
()
+
" requires exactly one argument."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
return
arguments
.
front
()
->
clone
();
}
...
...
@@ -803,12 +772,11 @@ public:
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
1
;
}
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
1
)
throw
Exception
(
"Function "
+
getName
()
+
" requires exactly one argument."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
const
DataTypeArray
*
arr
=
typeid_cast
<
const
DataTypeArray
*>
(
&*
arguments
[
0
]);
if
(
!
arr
)
throw
Exception
(
"Argument for function "
+
getName
()
+
" must be Array."
,
ErrorCodes
::
ILLEGAL_TYPE_OF_ARGUMENT
);
...
...
@@ -839,14 +807,11 @@ public:
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
2
;
}
/// Получить типы результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
2
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 2."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
const
DataTypeArray
*
array_type
=
typeid_cast
<
const
DataTypeArray
*>
(
&*
arguments
[
1
]);
if
(
!
array_type
)
throw
Exception
(
"Second argument for function "
+
getName
()
+
" must be array."
,
ErrorCodes
::
ILLEGAL_TYPE_OF_ARGUMENT
);
...
...
@@ -891,6 +856,9 @@ public:
return
name
;
}
bool
isVariadic
()
const
override
{
return
true
;
}
size_t
getNumberOfArguments
()
const
override
{
return
0
;
}
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
...
...
@@ -1048,16 +1016,10 @@ public:
String
getName
()
const
override
{
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
1
;
}
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
const
auto
args_size
=
arguments
.
size
();
if
(
args_size
!=
1
)
throw
Exception
{
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
args_size
)
+
", should be 1"
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
};
const
auto
arg
=
arguments
.
front
().
get
();
if
(
!
typeid_cast
<
const
DataTypeUInt8
*>
(
arg
)
&&
!
typeid_cast
<
const
DataTypeUInt16
*>
(
arg
)
&&
...
...
@@ -1161,10 +1123,10 @@ public:
String
getName
()
const
override
{
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
0
;
}
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
!
arguments
.
empty
())
throw
Exception
(
"Function "
+
getName
()
+
" must be called without arguments"
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
return
std
::
make_shared
<
DataTypeString
>
();
}
...
...
@@ -1191,10 +1153,10 @@ public:
String
getName
()
const
override
{
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
0
;
}
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
!
arguments
.
empty
())
throw
Exception
(
"Function "
+
getName
()
+
" must be called without arguments"
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
return
std
::
make_shared
<
DataTypeUInt32
>
();
}
...
...
@@ -1222,11 +1184,10 @@ public:
String
getName
()
const
override
{
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
1
;
}
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
1
)
throw
Exception
(
"Function "
+
getName
()
+
" requires exactly one argument."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
const
DataTypeAggregateFunction
*
type
=
typeid_cast
<
const
DataTypeAggregateFunction
*>
(
&*
arguments
[
0
]);
if
(
!
type
)
throw
Exception
(
"Argument for function "
+
getName
()
+
" must have type AggregateFunction - state of aggregate function."
,
...
...
@@ -1335,11 +1296,10 @@ public:
String
getName
()
const
override
{
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
1
;
}
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
1
)
throw
Exception
(
"Function "
+
getName
()
+
" requires exactly one argument."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
DataTypePtr
res
;
dispatchForSourceType
(
*
arguments
[
0
],
[
&
]
(
auto
field_type_tag
)
{
...
...
@@ -1384,11 +1344,10 @@ public:
String
getName
()
const
override
{
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
1
;
}
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
1
)
throw
Exception
(
"Function "
+
getName
()
+
" requires exactly one argument."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
const
DataTypeAggregateFunction
*
type
=
typeid_cast
<
const
DataTypeAggregateFunction
*>
(
&*
arguments
[
0
]);
if
(
!
type
)
throw
Exception
(
"Argument for function "
+
getName
()
+
" must have type AggregateFunction - state of aggregate function."
,
...
...
@@ -1417,12 +1376,13 @@ class FunctionHasColumnInTable : public IFunction
{
public:
static
constexpr
auto
name
=
"hasColumnInTable"
;
static
constexpr
size_t
number_of_arguments
=
3
;
size_t
getNumberOfArguments
()
const
override
{
return
3
;
}
static
FunctionPtr
create
(
const
Context
&
context
)
{
return
std
::
make_shared
<
FunctionHasColumnInTable
>
(
context
.
getGlobalContext
());
}
FunctionHasColumnInTable
(
const
Context
&
global_context_
)
:
global_context
(
global_context_
)
:
global_context
(
global_context_
)
{
}
...
...
dbms/include/DB/Functions/FunctionsNull.h
浏览文件 @
3f678a30
...
...
@@ -19,6 +19,7 @@ public:
static
FunctionPtr
create
(
const
Context
&
context
);
std
::
string
getName
()
const
override
;
size_t
getNumberOfArguments
()
const
override
{
return
1
;
}
bool
hasSpecialSupportForNulls
()
const
override
;
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
;
void
executeImpl
(
Block
&
block
,
const
ColumnNumbers
&
arguments
,
size_t
result
)
override
;
...
...
@@ -33,6 +34,7 @@ public:
static
FunctionPtr
create
(
const
Context
&
context
);
std
::
string
getName
()
const
override
;
size_t
getNumberOfArguments
()
const
override
{
return
1
;
}
bool
hasSpecialSupportForNulls
()
const
override
;
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
;
void
executeImpl
(
Block
&
block
,
const
ColumnNumbers
&
arguments
,
size_t
result
)
override
;
...
...
@@ -49,6 +51,8 @@ public:
std
::
string
getName
()
const
override
;
bool
hasSpecialSupportForNulls
()
const
override
;
bool
isVariadic
()
const
override
{
return
true
;
}
size_t
getNumberOfArguments
()
const
override
{
return
0
;
}
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
;
void
executeImpl
(
Block
&
block
,
const
ColumnNumbers
&
arguments
,
size_t
result
)
override
;
};
...
...
@@ -63,6 +67,7 @@ public:
static
FunctionPtr
create
(
const
Context
&
context
);
std
::
string
getName
()
const
override
;
size_t
getNumberOfArguments
()
const
override
{
return
2
;
}
bool
hasSpecialSupportForNulls
()
const
override
;
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
;
void
executeImpl
(
Block
&
block
,
const
ColumnNumbers
&
arguments
,
size_t
result
)
override
;
...
...
@@ -78,6 +83,7 @@ public:
static
FunctionPtr
create
(
const
Context
&
context
);
std
::
string
getName
()
const
override
;
size_t
getNumberOfArguments
()
const
override
{
return
2
;
}
bool
hasSpecialSupportForNulls
()
const
override
;
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
;
void
executeImpl
(
Block
&
block
,
const
ColumnNumbers
&
arguments
,
size_t
result
)
override
;
...
...
@@ -94,6 +100,7 @@ public:
static
FunctionPtr
create
(
const
Context
&
context
);
std
::
string
getName
()
const
override
;
size_t
getNumberOfArguments
()
const
override
{
return
1
;
}
bool
hasSpecialSupportForNulls
()
const
override
;
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
;
void
executeImpl
(
Block
&
block
,
const
ColumnNumbers
&
arguments
,
size_t
result
)
override
;
...
...
dbms/include/DB/Functions/FunctionsRandom.h
浏览文件 @
3f678a30
...
...
@@ -158,6 +158,9 @@ public:
return
name
;
}
bool
isVariadic
()
const
override
{
return
true
;
}
size_t
getNumberOfArguments
()
const
override
{
return
0
;
}
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
...
...
@@ -204,6 +207,9 @@ public:
return
name
;
}
bool
isVariadic
()
const
override
{
return
true
;
}
size_t
getNumberOfArguments
()
const
override
{
return
0
;
}
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
...
...
dbms/include/DB/Functions/FunctionsReinterpret.h
浏览文件 @
3f678a30
...
...
@@ -32,14 +32,11 @@ public:
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
1
;
}
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
1
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 1."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
const
IDataType
*
type
=
&*
arguments
[
0
];
if
(
!
type
->
isNumeric
()
&&
!
typeid_cast
<
const
DataTypeDate
*>
(
type
)
&&
...
...
@@ -130,14 +127,11 @@ public:
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
1
;
}
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
1
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 1."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
const
IDataType
*
type
=
&*
arguments
[
0
];
if
(
!
typeid_cast
<
const
DataTypeString
*>
(
type
)
&&
!
typeid_cast
<
const
DataTypeFixedString
*>
(
type
))
...
...
dbms/include/DB/Functions/FunctionsRound.h
浏览文件 @
3f678a30
...
...
@@ -1067,6 +1067,9 @@ namespace
return
name
;
}
bool
isVariadic
()
const
override
{
return
true
;
}
size_t
getNumberOfArguments
()
const
override
{
return
0
;
}
/// Получить типы результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
...
...
dbms/include/DB/Functions/FunctionsString.h
浏览文件 @
3f678a30
...
...
@@ -779,14 +779,11 @@ public:
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
1
;
}
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
1
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 1."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
if
(
!
typeid_cast
<
const
DataTypeString
*>
(
&*
arguments
[
0
])
&&
!
typeid_cast
<
const
DataTypeFixedString
*>
(
&*
arguments
[
0
])
&&
!
typeid_cast
<
const
DataTypeArray
*>
(
&*
arguments
[
0
]))
throw
Exception
(
"Illegal type "
+
arguments
[
0
]
->
getName
()
+
" of argument of function "
+
getName
(),
...
...
@@ -875,14 +872,11 @@ public:
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
1
;
}
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
1
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 1."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
if
(
!
typeid_cast
<
const
DataTypeString
*>
(
&*
arguments
[
0
])
&&
!
typeid_cast
<
const
DataTypeFixedString
*>
(
&*
arguments
[
0
]))
throw
Exception
(
"Illegal type "
+
arguments
[
0
]
->
getName
()
+
" of argument of function "
+
getName
(),
ErrorCodes
::
ILLEGAL_TYPE_OF_ARGUMENT
);
...
...
@@ -933,6 +927,7 @@ public:
/// Получить имя функции.
String
getName
()
const
override
;
size_t
getNumberOfArguments
()
const
override
{
return
1
;
}
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
;
/// Выполнить функцию над блоком.
...
...
@@ -953,6 +948,9 @@ public:
return
name
;
}
bool
isVariadic
()
const
override
{
return
true
;
}
size_t
getNumberOfArguments
()
const
override
{
return
0
;
}
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
...
...
@@ -1432,14 +1430,11 @@ public:
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
3
;
}
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
3
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 3."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
if
(
!
typeid_cast
<
const
DataTypeString
*>
(
&*
arguments
[
0
])
&&
!
typeid_cast
<
const
DataTypeFixedString
*>
(
&*
arguments
[
0
]))
throw
Exception
(
"Illegal type "
+
arguments
[
0
]
->
getName
()
+
" of argument of function "
+
getName
(),
ErrorCodes
::
ILLEGAL_TYPE_OF_ARGUMENT
);
...
...
@@ -1519,6 +1514,7 @@ public:
String
getName
()
const
override
;
private:
size_t
getNumberOfArguments
()
const
override
{
return
2
;
}
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
;
void
executeImpl
(
Block
&
block
,
const
ColumnNumbers
&
arguments
,
const
size_t
result
)
override
;
};
...
...
dbms/include/DB/Functions/FunctionsStringArray.h
浏览文件 @
3f678a30
...
...
@@ -49,14 +49,11 @@ public:
static
constexpr
auto
name
=
"alphaTokens"
;
static
String
getName
()
{
return
name
;
}
static
size_t
getNumberOfArguments
()
{
return
1
;
}
/// Проверить типы агрументов функции.
static
void
checkArguments
(
const
DataTypes
&
arguments
)
{
if
(
arguments
.
size
()
!=
1
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 1."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
if
(
!
typeid_cast
<
const
DataTypeString
*>
(
&*
arguments
[
0
]))
throw
Exception
(
"Illegal type "
+
arguments
[
0
]
->
getName
()
+
" of first argument of function "
+
getName
()
+
". Must be String."
,
ErrorCodes
::
ILLEGAL_TYPE_OF_ARGUMENT
);
...
...
@@ -111,14 +108,10 @@ private:
public:
static
constexpr
auto
name
=
"splitByChar"
;
static
String
getName
()
{
return
name
;
}
static
size_t
getNumberOfArguments
()
{
return
2
;
}
static
void
checkArguments
(
const
DataTypes
&
arguments
)
{
if
(
arguments
.
size
()
!=
2
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 2."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
if
(
!
typeid_cast
<
const
DataTypeString
*>
(
&*
arguments
[
0
]))
throw
Exception
(
"Illegal type "
+
arguments
[
0
]
->
getName
()
+
" of first argument of function "
+
getName
()
+
". Must be String."
,
ErrorCodes
::
ILLEGAL_TYPE_OF_ARGUMENT
);
...
...
@@ -189,6 +182,7 @@ private:
public:
static
constexpr
auto
name
=
"splitByString"
;
static
String
getName
()
{
return
name
;
}
static
size_t
getNumberOfArguments
()
{
return
2
;
}
static
void
checkArguments
(
const
DataTypes
&
arguments
)
{
...
...
@@ -251,9 +245,9 @@ private:
Pos
pos
;
Pos
end
;
public:
/// Получить имя функции.
static
constexpr
auto
name
=
"extractAll"
;
static
String
getName
()
{
return
name
;
}
static
size_t
getNumberOfArguments
()
{
return
2
;
}
/// Проверить типы агрументов функции.
static
void
checkArguments
(
const
DataTypes
&
arguments
)
...
...
@@ -322,6 +316,8 @@ public:
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
Generator
::
getNumberOfArguments
();
}
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
...
...
@@ -487,6 +483,9 @@ public:
return
name
;
}
bool
isVariadic
()
const
override
{
return
true
;
}
size_t
getNumberOfArguments
()
const
override
{
return
0
;
}
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
...
...
dbms/include/DB/Functions/FunctionsStringSearch.h
浏览文件 @
3f678a30
...
...
@@ -1129,14 +1129,11 @@ public:
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
3
;
}
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
3
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 3."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
if
(
!
typeid_cast
<
const
DataTypeString
*>
(
&*
arguments
[
0
])
&&
!
typeid_cast
<
const
DataTypeFixedString
*>
(
&*
arguments
[
0
]))
throw
Exception
(
"Illegal type "
+
arguments
[
0
]
->
getName
()
+
" of first argument of function "
+
getName
(),
ErrorCodes
::
ILLEGAL_TYPE_OF_ARGUMENT
);
...
...
@@ -1216,14 +1213,11 @@ public:
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
2
;
}
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
2
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 2."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
if
(
!
typeid_cast
<
const
DataTypeString
*>
(
&*
arguments
[
0
]))
throw
Exception
(
"Illegal type "
+
arguments
[
0
]
->
getName
()
+
" of argument of function "
+
getName
(),
ErrorCodes
::
ILLEGAL_TYPE_OF_ARGUMENT
);
...
...
@@ -1301,14 +1295,11 @@ public:
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
2
;
}
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
2
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 2."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
if
(
!
typeid_cast
<
const
DataTypeString
*>
(
&*
arguments
[
0
]))
throw
Exception
(
"Illegal type "
+
arguments
[
0
]
->
getName
()
+
" of argument of function "
+
getName
(),
ErrorCodes
::
ILLEGAL_TYPE_OF_ARGUMENT
);
...
...
dbms/include/DB/Functions/FunctionsTransform.h
浏览文件 @
3f678a30
...
...
@@ -55,6 +55,9 @@ public:
return
name
;
}
bool
isVariadic
()
const
override
{
return
true
;
}
size_t
getNumberOfArguments
()
const
override
{
return
0
;
}
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
const
auto
args_size
=
arguments
.
size
();
...
...
dbms/include/DB/Functions/FunctionsURL.h
浏览文件 @
3f678a30
...
...
@@ -562,13 +562,10 @@ public:
static
constexpr
auto
name
=
"extractURLParameters"
;
static
String
getName
()
{
return
name
;
}
static
size_t
getNumberOfArguments
()
{
return
1
;
}
static
void
checkArguments
(
const
DataTypes
&
arguments
)
{
if
(
arguments
.
size
()
!=
1
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 1."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
if
(
!
typeid_cast
<
const
DataTypeString
*>
(
&*
arguments
[
0
]))
throw
Exception
(
"Illegal type "
+
arguments
[
0
]
->
getName
()
+
" of first argument of function "
+
getName
()
+
". Must be String."
,
ErrorCodes
::
ILLEGAL_TYPE_OF_ARGUMENT
);
...
...
@@ -650,13 +647,10 @@ public:
static
constexpr
auto
name
=
"extractURLParameterNames"
;
static
String
getName
()
{
return
name
;
}
static
size_t
getNumberOfArguments
()
{
return
1
;
}
static
void
checkArguments
(
const
DataTypes
&
arguments
)
{
if
(
arguments
.
size
()
!=
1
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 1."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
if
(
!
typeid_cast
<
const
DataTypeString
*>
(
&*
arguments
[
0
]))
throw
Exception
(
"Illegal type "
+
arguments
[
0
]
->
getName
()
+
" of first argument of function "
+
getName
()
+
". Must be String."
,
ErrorCodes
::
ILLEGAL_TYPE_OF_ARGUMENT
);
...
...
@@ -730,13 +724,10 @@ public:
static
constexpr
auto
name
=
"URLHierarchy"
;
static
String
getName
()
{
return
name
;
}
static
size_t
getNumberOfArguments
()
{
return
1
;
}
static
void
checkArguments
(
const
DataTypes
&
arguments
)
{
if
(
arguments
.
size
()
!=
1
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 1."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
if
(
!
typeid_cast
<
const
DataTypeString
*>
(
&*
arguments
[
0
]))
throw
Exception
(
"Illegal type "
+
arguments
[
0
]
->
getName
()
+
" of first argument of function "
+
getName
()
+
". Must be String."
,
ErrorCodes
::
ILLEGAL_TYPE_OF_ARGUMENT
);
...
...
@@ -829,13 +820,10 @@ public:
static
constexpr
auto
name
=
"URLPathHierarchy"
;
static
String
getName
()
{
return
name
;
}
static
size_t
getNumberOfArguments
()
{
return
1
;
}
static
void
checkArguments
(
const
DataTypes
&
arguments
)
{
if
(
arguments
.
size
()
!=
1
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 1."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
if
(
!
typeid_cast
<
const
DataTypeString
*>
(
&*
arguments
[
0
]))
throw
Exception
(
"Illegal type "
+
arguments
[
0
]
->
getName
()
+
" of first argument of function "
+
getName
()
+
". Must be String."
,
ErrorCodes
::
ILLEGAL_TYPE_OF_ARGUMENT
);
...
...
dbms/include/DB/Functions/IFunction.h
浏览文件 @
3f678a30
...
...
@@ -49,6 +49,16 @@ public:
/// Получить основное имя функции.
virtual
String
getName
()
const
=
0
;
/// Override and return true if function could take different number of arguments.
virtual
bool
isVariadic
()
const
{
return
false
;
}
/// For non-variadic functions, return number of arguments; otherwise return zero (that should be ignored).
virtual
size_t
getNumberOfArguments
()
const
=
0
;
/// Throw if number of arguments is incorrect. Default implementation will check only in non-variadic case.
/// It is called inside getReturnType.
virtual
void
checkNumberOfArguments
(
size_t
number_of_arguments
)
const
;
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
/// Перегрузка для тех, кому не нужны prerequisites и значения константных аргументов. Снаружи не вызывается.
DataTypePtr
getReturnType
(
const
DataTypes
&
arguments
)
const
;
...
...
dbms/src/Functions/FunctionsArray.cpp
浏览文件 @
3f678a30
...
...
@@ -1035,11 +1035,6 @@ String FunctionArrayElement::getName() const
DataTypePtr
FunctionArrayElement
::
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
{
if
(
arguments
.
size
()
!=
2
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 2."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
const
DataTypeArray
*
array_type
=
typeid_cast
<
const
DataTypeArray
*>
(
arguments
[
0
].
get
());
if
(
!
array_type
)
throw
Exception
(
"First argument for function "
+
getName
()
+
" must be array."
,
ErrorCodes
::
ILLEGAL_TYPE_OF_ARGUMENT
);
...
...
@@ -1201,11 +1196,6 @@ String FunctionArrayEnumerate::getName() const
DataTypePtr
FunctionArrayEnumerate
::
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
{
if
(
arguments
.
size
()
!=
1
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 1."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
const
DataTypeArray
*
array_type
=
typeid_cast
<
const
DataTypeArray
*>
(
arguments
[
0
].
get
());
if
(
!
array_type
)
throw
Exception
(
"First argument for function "
+
getName
()
+
" must be an array but it has type "
...
...
@@ -1904,11 +1894,6 @@ String FunctionEmptyArrayToSingle::getName() const
DataTypePtr
FunctionEmptyArrayToSingle
::
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
{
if
(
arguments
.
size
()
!=
1
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 1."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
const
DataTypeArray
*
array_type
=
typeid_cast
<
const
DataTypeArray
*>
(
arguments
[
0
].
get
());
if
(
!
array_type
)
throw
Exception
(
"Argument for function "
+
getName
()
+
" must be array."
,
...
...
@@ -2197,13 +2182,6 @@ String FunctionRange::getName() const
DataTypePtr
FunctionRange
::
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
{
if
(
arguments
.
size
()
!=
1
)
throw
Exception
{
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 1."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
};
const
auto
arg
=
arguments
.
front
().
get
();
if
(
!
typeid_cast
<
const
DataTypeUInt8
*>
(
arg
)
&&
...
...
@@ -2334,11 +2312,6 @@ String FunctionArrayReverse::getName() const
DataTypePtr
FunctionArrayReverse
::
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
{
if
(
arguments
.
size
()
!=
1
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 1."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
const
DataTypeArray
*
array_type
=
typeid_cast
<
const
DataTypeArray
*>
(
arguments
[
0
].
get
());
if
(
!
array_type
)
throw
Exception
(
"Argument for function "
+
getName
()
+
" must be array."
,
...
...
dbms/src/Functions/FunctionsCharset.cpp
浏览文件 @
3f678a30
...
...
@@ -141,13 +141,10 @@ public:
return
name
;
}
size_t
getNumberOfArguments
()
const
override
{
return
3
;
}
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
!=
3
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 3."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
for
(
size_t
i
:
ext
::
range
(
0
,
3
))
if
(
!
typeid_cast
<
const
DataTypeString
*>
(
&*
arguments
[
i
]))
throw
Exception
(
"Illegal type "
+
arguments
[
i
]
->
getName
()
+
" of argument of function "
+
getName
()
...
...
dbms/src/Functions/FunctionsMiscellaneous.cpp
浏览文件 @
3f678a30
...
...
@@ -495,12 +495,8 @@ void FunctionHasColumnInTable::getReturnTypeAndPrerequisitesImpl(
DataTypePtr
&
out_return_type
,
ExpressionActions
::
Actions
&
out_prerequisites
)
{
if
(
arguments
.
size
()
!=
number_of_arguments
)
throw
Exception
(
"Function "
+
getName
()
+
" requires exactly three arguments."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
static
const
std
::
string
arg_pos_description
[]
=
{
"First"
,
"Second"
,
"Third"
};
for
(
size_t
i
=
0
;
i
<
number_of_arguments
;
++
i
)
for
(
size_t
i
=
0
;
i
<
getNumberOfArguments
()
;
++
i
)
{
const
ColumnWithTypeAndName
&
argument
=
arguments
[
i
];
...
...
dbms/src/Functions/FunctionsNull.cpp
浏览文件 @
3f678a30
...
...
@@ -41,11 +41,6 @@ bool FunctionIsNull::hasSpecialSupportForNulls() const
DataTypePtr
FunctionIsNull
::
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
{
if
(
arguments
.
size
()
!=
1
)
throw
Exception
{
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 1."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
};
return
std
::
make_shared
<
DataTypeUInt8
>
();
}
...
...
@@ -90,11 +85,6 @@ bool FunctionIsNotNull::hasSpecialSupportForNulls() const
DataTypePtr
FunctionIsNotNull
::
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
{
if
(
arguments
.
size
()
!=
1
)
throw
Exception
{
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 1."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
};
return
std
::
make_shared
<
DataTypeUInt8
>
();
}
...
...
@@ -207,11 +197,6 @@ bool FunctionIfNull::hasSpecialSupportForNulls() const
DataTypePtr
FunctionIfNull
::
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
{
if
(
arguments
.
size
()
!=
2
)
throw
Exception
{
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 2."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
};
return
FunctionMultiIf
{}.
getReturnTypeImpl
({
std
::
make_shared
<
DataTypeUInt8
>
(),
arguments
[
0
],
arguments
[
1
]});
}
...
...
@@ -249,11 +234,6 @@ bool FunctionNullIf::hasSpecialSupportForNulls() const
DataTypePtr
FunctionNullIf
::
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
{
if
(
arguments
.
size
()
!=
2
)
throw
Exception
{
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 2."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
};
return
FunctionMultiIf
{}.
getReturnTypeImpl
({
std
::
make_shared
<
DataTypeUInt8
>
(),
std
::
make_shared
<
DataTypeNull
>
(),
arguments
[
0
]});
}
...
...
@@ -303,11 +283,6 @@ bool FunctionAssumeNotNull::hasSpecialSupportForNulls() const
DataTypePtr
FunctionAssumeNotNull
::
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
{
if
(
arguments
.
size
()
!=
1
)
throw
Exception
{
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 1."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
};
if
(
arguments
[
0
]
->
isNull
())
throw
Exception
{
"NULL is an invalid value for function "
+
getName
(),
ErrorCodes
::
ILLEGAL_TYPE_OF_ARGUMENT
};
else
if
(
arguments
[
0
]
->
isNullable
())
...
...
dbms/src/Functions/FunctionsString.cpp
浏览文件 @
3f678a30
...
...
@@ -13,11 +13,6 @@ String FunctionReverse::getName() const
DataTypePtr
FunctionReverse
::
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
{
if
(
arguments
.
size
()
!=
1
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 1."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
if
(
!
typeid_cast
<
const
DataTypeString
*>
(
&*
arguments
[
0
])
&&
!
typeid_cast
<
const
DataTypeFixedString
*>
(
&*
arguments
[
0
])
&&
!
typeid_cast
<
const
DataTypeArray
*>
(
&*
arguments
[
0
]))
throw
Exception
(
"Illegal type "
+
arguments
[
0
]
->
getName
()
+
" of argument of function "
+
getName
(),
...
...
@@ -71,13 +66,6 @@ String FunctionAppendTrailingCharIfAbsent::getName() const
DataTypePtr
FunctionAppendTrailingCharIfAbsent
::
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
{
if
(
arguments
.
size
()
!=
2
)
throw
Exception
{
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
arguments
.
size
())
+
", should be 2."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
};
if
(
!
typeid_cast
<
const
DataTypeString
*>
(
arguments
[
0
].
get
()))
throw
Exception
{
"Illegal type "
+
arguments
[
0
]
->
getName
()
+
" of argument of function "
+
getName
(),
...
...
dbms/src/Functions/IFunction.cpp
浏览文件 @
3f678a30
...
...
@@ -168,32 +168,47 @@ DataTypes toNestedDataTypes(const DataTypes & args)
}
void
IFunction
::
checkNumberOfArguments
(
size_t
number_of_arguments
)
const
{
if
(
isVariadic
())
return
;
size_t
expected_number_of_arguments
=
getNumberOfArguments
();
if
(
number_of_arguments
!=
expected_number_of_arguments
)
throw
Exception
(
"Number of arguments for function "
+
getName
()
+
" doesn't match: passed "
+
toString
(
number_of_arguments
)
+
", should be "
+
toString
(
expected_number_of_arguments
),
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
}
DataTypePtr
IFunction
::
getReturnType
(
const
DataTypes
&
arguments
)
const
{
checkNumberOfArguments
(
arguments
.
size
());
auto
category
=
hasSpecialDataTypes
(
arguments
);
if
(
category
==
Category
::
IS_ORDINARY
)
{
}
else
if
(
category
==
Category
::
IS_NULL
)
{
if
(
!
hasSpecialSupportForNulls
())
return
std
::
make_shared
<
DataTypeNull
>
();
}
else
if
(
category
==
Category
::
IS_NULLABLE
)
switch
(
category
)
{
if
(
!
hasSpecialSupportForNulls
())
{
const
DataTypes
new_args
=
toNestedDataTypes
(
arguments
);
return
getReturnTypeImpl
(
new_args
);
}
case
Category
::
IS_ORDINARY
:
break
;
case
Category
::
IS_NULL
:
if
(
!
hasSpecialSupportForNulls
())
return
std
::
make_shared
<
DataTypeNull
>
();
break
;
case
Category
::
IS_NULLABLE
:
if
(
!
hasSpecialSupportForNulls
())
return
getReturnTypeImpl
(
toNestedDataTypes
(
arguments
));
break
;
}
else
throw
Exception
{
"IFunction: internal error"
,
ErrorCodes
::
LOGICAL_ERROR
};
return
getReturnTypeImpl
(
arguments
);
}
void
IFunction
::
getReturnTypeAndPrerequisites
(
const
ColumnsWithTypeAndName
&
arguments
,
DataTypePtr
&
out_return_type
,
...
...
@@ -201,61 +216,63 @@ void IFunction::getReturnTypeAndPrerequisites(
{
auto
category
=
hasSpecialColumns
(
arguments
);
if
(
category
==
Category
::
IS_ORDINARY
)
{
}
else
if
(
category
==
Category
::
IS_NULL
)
{
if
(
!
hasSpecialSupportForNulls
())
{
out_return_type
=
std
::
make_shared
<
DataTypeNull
>
();
return
;
}
}
else
if
(
category
==
Category
::
IS_NULLABLE
)
switch
(
category
)
{
if
(
!
hasSpecialSupportForNulls
())
{
const
ColumnsWithTypeAndName
new_args
=
toNestedColumns
(
arguments
);
getReturnTypeAndPrerequisitesImpl
(
new_args
,
out_return_type
,
out_prerequisites
);
out_return_type
=
std
::
make_shared
<
DataTypeNullable
>
(
out_return_type
);
return
;
}
case
Category
::
IS_ORDINARY
:
break
;
case
Category
::
IS_NULL
:
if
(
!
hasSpecialSupportForNulls
())
{
out_return_type
=
std
::
make_shared
<
DataTypeNull
>
();
return
;
}
break
;
case
Category
::
IS_NULLABLE
:
if
(
!
hasSpecialSupportForNulls
())
{
const
ColumnsWithTypeAndName
new_args
=
toNestedColumns
(
arguments
);
getReturnTypeAndPrerequisitesImpl
(
new_args
,
out_return_type
,
out_prerequisites
);
out_return_type
=
std
::
make_shared
<
DataTypeNullable
>
(
out_return_type
);
return
;
}
break
;
}
else
throw
Exception
{
"IFunction: internal error"
,
ErrorCodes
::
LOGICAL_ERROR
};
getReturnTypeAndPrerequisitesImpl
(
arguments
,
out_return_type
,
out_prerequisites
);
}
void
IFunction
::
getLambdaArgumentTypes
(
DataTypes
&
arguments
)
const
{
auto
category
=
hasSpecialDataTypes
(
arguments
);
if
(
category
==
Category
::
IS_ORDINARY
)
switch
(
category
)
{
case
Category
::
IS_ORDINARY
:
break
;
case
Category
::
IS_NULL
:
if
(
!
hasSpecialSupportForNulls
())
return
;
break
;
case
Category
::
IS_NULLABLE
:
if
(
!
hasSpecialSupportForNulls
())
{
DataTypes
new_args
=
toNestedDataTypes
(
arguments
);
getLambdaArgumentTypesImpl
(
new_args
);
arguments
=
std
::
move
(
new_args
);
return
;
}
break
;
}
else
if
(
category
==
Category
::
IS_NULL
)
{
if
(
!
hasSpecialSupportForNulls
())
return
;
}
else
if
(
category
==
Category
::
IS_NULLABLE
)
{
if
(
!
hasSpecialSupportForNulls
())
{
DataTypes
new_args
=
toNestedDataTypes
(
arguments
);
getLambdaArgumentTypesImpl
(
new_args
);
arguments
=
std
::
move
(
new_args
);
return
;
}
}
else
throw
Exception
{
"IFunction: internal error"
,
ErrorCodes
::
LOGICAL_ERROR
};
getLambdaArgumentTypesImpl
(
arguments
);
}
void
IFunction
::
execute
(
Block
&
block
,
const
ColumnNumbers
&
args
,
size_t
result
)
{
auto
strategy
=
chooseStrategy
(
block
,
args
);
...
...
@@ -270,6 +287,7 @@ void IFunction::execute(Block & block, const ColumnNumbers & args, size_t result
postProcessResult
(
strategy
,
block
,
processed_block
,
args
,
result
);
}
void
IFunction
::
execute
(
Block
&
block
,
const
ColumnNumbers
&
args
,
const
ColumnNumbers
&
prerequisites
,
size_t
result
)
{
auto
strategy
=
chooseStrategy
(
block
,
args
);
...
...
@@ -284,29 +302,31 @@ void IFunction::execute(Block & block, const ColumnNumbers & args, const ColumnN
postProcessResult
(
strategy
,
block
,
processed_block
,
args
,
result
);
}
IFunction
::
Strategy
IFunction
::
chooseStrategy
(
const
Block
&
block
,
const
ColumnNumbers
&
args
)
{
auto
category
=
blockHasSpecialColumns
(
block
,
args
);
if
(
category
==
Category
::
IS_ORDINARY
)
{
}
else
if
(
category
==
Category
::
IS_NULL
)
switch
(
category
)
{
if
(
!
hasSpecialSupportForNulls
())
return
RETURN_NULL
;
}
else
if
(
category
==
Category
::
IS_NULLABLE
)
{
if
(
!
hasSpecialSupportForNulls
())
return
PROCESS_NULLABLE_COLUMNS
;
case
Category
::
IS_ORDINARY
:
break
;
case
Category
::
IS_NULL
:
if
(
!
hasSpecialSupportForNulls
())
return
RETURN_NULL
;
break
;
case
Category
::
IS_NULLABLE
:
if
(
!
hasSpecialSupportForNulls
())
return
PROCESS_NULLABLE_COLUMNS
;
break
;
}
else
throw
Exception
{
"IFunction: internal error"
,
ErrorCodes
::
LOGICAL_ERROR
};
return
DIRECTLY_EXECUTE
;
}
Block
IFunction
::
preProcessBlock
(
Strategy
strategy
,
const
Block
&
block
,
const
ColumnNumbers
&
args
,
size_t
result
)
{
if
(
strategy
==
DIRECTLY_EXECUTE
)
...
...
@@ -320,9 +340,10 @@ Block IFunction::preProcessBlock(Strategy strategy, const Block & block, const C
return
createBlockWithNestedColumns
(
block
,
args
,
result
);
}
else
throw
Exception
{
"IFunction:
internal error
"
,
ErrorCodes
::
LOGICAL_ERROR
};
throw
Exception
{
"IFunction:
logical error, unknown execution strategy.
"
,
ErrorCodes
::
LOGICAL_ERROR
};
}
void
IFunction
::
postProcessResult
(
Strategy
strategy
,
Block
&
block
,
const
Block
&
processed_block
,
const
ColumnNumbers
&
args
,
size_t
result
)
{
...
...
@@ -349,9 +370,10 @@ void IFunction::postProcessResult(Strategy strategy, Block & block, const Block
createNullValuesByteMap
(
block
,
args
,
result
);
}
else
throw
Exception
{
"IFunction:
internal error
"
,
ErrorCodes
::
LOGICAL_ERROR
};
throw
Exception
{
"IFunction:
logical error, unknown execution strategy.
"
,
ErrorCodes
::
LOGICAL_ERROR
};
}
Block
IFunction
::
createBlockWithNestedColumns
(
const
Block
&
block
,
ColumnNumbers
args
)
{
std
::
sort
(
args
.
begin
(),
args
.
end
());
...
...
@@ -389,6 +411,7 @@ Block IFunction::createBlockWithNestedColumns(const Block & block, ColumnNumbers
return
res
;
}
Block
IFunction
::
createBlockWithNestedColumns
(
const
Block
&
block
,
ColumnNumbers
args
,
size_t
result
)
{
std
::
sort
(
args
.
begin
(),
args
.
end
());
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录