Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
1d4d01a7
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,发现更多精彩内容 >>
提交
1d4d01a7
编写于
8月 23, 2012
作者:
A
Alexey Milovidov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
dbms: development [#CONV-2944].
上级
7620dfe4
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
41 addition
and
17 deletion
+41
-17
dbms/include/DB/Functions/FunctionsMiscellaneous.h
dbms/include/DB/Functions/FunctionsMiscellaneous.h
+1
-1
dbms/include/DB/Parsers/ASTSet.h
dbms/include/DB/Parsers/ASTSet.h
+4
-2
dbms/src/AggregateFunctions/AggregateFunctionFactory.cpp
dbms/src/AggregateFunctions/AggregateFunctionFactory.cpp
+18
-11
dbms/src/Interpreters/Expression.cpp
dbms/src/Interpreters/Expression.cpp
+18
-3
未找到文件。
dbms/include/DB/Functions/FunctionsMiscellaneous.h
浏览文件 @
1d4d01a7
...
...
@@ -345,7 +345,7 @@ public:
DataTypePtr
getReturnType
(
const
DataTypes
&
arguments
)
const
{
if
(
arguments
.
size
()
!=
2
)
throw
Exception
(
"Number of arguments for function
"
+
getName
()
+
"
doesn't match: passed "
throw
Exception
(
"Number of arguments for function
'"
+
getName
()
+
"'
doesn't match: passed "
+
Poco
::
NumberFormatter
::
format
(
arguments
.
size
())
+
", should be 2."
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
...
...
dbms/include/DB/Parsers/ASTSet.h
浏览文件 @
1d4d01a7
...
...
@@ -14,11 +14,13 @@ class ASTSet : public IAST
{
public:
SetPtr
set
;
String
column_name
;
ASTSet
()
{}
ASTSet
(
StringRange
range_
)
:
IAST
(
rang
e_
)
{}
ASTSet
(
const
String
&
column_name_
)
:
column_name
(
column_name_
)
{}
ASTSet
(
StringRange
range_
,
const
String
&
column_name_
)
:
IAST
(
range_
),
column_name
(
column_nam
e_
)
{}
String
getID
()
{
return
"Set"
;
}
ASTPtr
clone
()
const
{
return
new
ASTSet
(
*
this
);
}
String
getColumnName
()
{
return
column_name
;
}
};
}
dbms/src/AggregateFunctions/AggregateFunctionFactory.cpp
浏览文件 @
1d4d01a7
#include <set>
#include <boost/assign/list_inserter.hpp>
#include <DB/AggregateFunctions/AggregateFunctionCount.h>
#include <DB/AggregateFunctions/AggregateFunctionSum.h>
#include <DB/AggregateFunctions/AggregateFunctionAvg.h>
...
...
@@ -152,17 +155,21 @@ AggregateFunctionPtr AggregateFunctionFactory::getByTypeID(const String & type_i
AggregateFunctionPtr
AggregateFunctionFactory
::
tryGet
(
const
String
&
name
,
const
DataTypes
&
argument_types
)
const
{
try
{
return
get
(
name
,
argument_types
);
}
catch
(
const
DB
::
Exception
&
e
)
{
if
(
e
.
code
()
==
ErrorCodes
::
UNKNOWN_AGGREGATE_FUNCTION
)
return
NULL
;
else
throw
;
}
std
::
set
<
String
>
names
;
boost
::
assign
::
insert
(
names
)
(
"count"
)
(
"any"
)
(
"anyLast"
)
(
"min"
)
(
"max"
)
(
"sum"
)
(
"avg"
)
(
"uniq"
);
return
names
.
end
()
!=
names
.
find
(
name
)
?
get
(
name
,
argument_types
)
:
NULL
;
}
...
...
dbms/src/Interpreters/Expression.cpp
浏览文件 @
1d4d01a7
...
...
@@ -9,6 +9,9 @@
#include <DB/Parsers/ASTSubquery.h>
#include <DB/Parsers/ASTSet.h>
#include <DB/DataTypes/DataTypeSet.h>
#include <DB/Columns/ColumnSet.h>
#include <DB/Interpreters/InterpreterSelectQuery.h>
#include <DB/Interpreters/Expression.h>
...
...
@@ -103,6 +106,8 @@ void Expression::addSemantic(ASTPtr & ast)
argument_types
.
push_back
(
arg
->
type
);
else
if
(
ASTLiteral
*
arg
=
dynamic_cast
<
ASTLiteral
*>
(
&**
it
))
argument_types
.
push_back
(
arg
->
type
);
else
if
(
dynamic_cast
<
ASTSubquery
*>
(
&**
it
)
||
dynamic_cast
<
ASTSet
*>
(
&**
it
))
argument_types
.
push_back
(
new
DataTypeSet
);
}
node
->
aggregate_function
=
context
.
getAggregateFunctionsFactory
().
tryGet
(
node
->
name
,
argument_types
);
...
...
@@ -257,6 +262,16 @@ void Expression::executeImpl(ASTPtr ast, Block & block, unsigned part_id, bool o
column
.
type
=
node
->
type
;
column
.
name
=
node
->
getColumnName
();
block
.
insert
(
column
);
}
else
if
(
ASTSet
*
node
=
dynamic_cast
<
ASTSet
*>
(
&*
ast
))
{
/// Множество в секции IN.
ColumnWithNameAndType
column
;
column
.
column
=
new
ColumnSet
(
block
.
rows
(),
node
->
set
);
column
.
type
=
new
DataTypeSet
;
column
.
name
=
node
->
getColumnName
();
block
.
insert
(
column
);
}
}
...
...
@@ -491,12 +506,12 @@ void Expression::makeSetsImpl(ASTPtr ast)
* Это может быть перечисление значений или подзапрос.
* Перечисление значений парсится как функция tuple.
*/
ASTPtr
arg
=
args
.
children
[
1
];
ASTPtr
&
arg
=
args
.
children
[
1
];
if
(
dynamic_cast
<
ASTSubquery
*>
(
&*
arg
))
{
/// Исполняем подзапрос, превращаем результат в множество, и кладём это множество на место подзапроса.
InterpreterSelectQuery
interpreter
(
arg
,
context
,
QueryProcessingStage
::
Complete
);
ASTSet
*
ast_set
=
new
ASTSet
;
InterpreterSelectQuery
interpreter
(
arg
->
children
[
0
]
,
context
,
QueryProcessingStage
::
Complete
);
ASTSet
*
ast_set
=
new
ASTSet
(
arg
->
getColumnName
())
;
ast_set
->
set
=
new
Set
;
ast_set
->
set
->
create
(
interpreter
.
execute
());
arg
=
ast_set
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录