Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
9042e61e
提交
9042e61e
authored
12月 15, 2018
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Parse ALL in aggregates
上级
7d843c06
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
32 行增加
和
15 行删除
+32
-15
help.csv
h2/src/docsrc/help/help.csv
+10
-10
Parser.java
h2/src/main/org/h2/command/Parser.java
+13
-5
sum.sql
h2/src/test/org/h2/test/scripts/functions/aggregate/sum.sql
+9
-0
没有找到文件。
h2/src/docsrc/help/help.csv
浏览文件 @
9042e61e
...
@@ -3418,7 +3418,7 @@ INTERVAL MINUTE TO SECOND
...
@@ -3418,7 +3418,7 @@ INTERVAL MINUTE TO SECOND
"
"
"Functions (Aggregate)","AVG","
"Functions (Aggregate)","AVG","
AVG ( [ DISTINCT ] { numeric } )
AVG ( [ DISTINCT
|ALL
] { numeric } )
[FILTER (WHERE expression)] [OVER windowNameOrSpecification]
[FILTER (WHERE expression)] [OVER windowNameOrSpecification]
","
","
The average (mean) value.
The average (mean) value.
...
@@ -3474,7 +3474,7 @@ ANY(NAME LIKE 'W%')
...
@@ -3474,7 +3474,7 @@ ANY(NAME LIKE 'W%')
"
"
"Functions (Aggregate)","COUNT","
"Functions (Aggregate)","COUNT","
COUNT( { * | { [ DISTINCT ] expression } } )
COUNT( { * | { [ DISTINCT
|ALL
] expression } } )
[FILTER (WHERE expression)] [OVER windowNameOrSpecification]
[FILTER (WHERE expression)] [OVER windowNameOrSpecification]
","
","
The count of all row, or of the non-null values.
The count of all row, or of the non-null values.
...
@@ -3486,7 +3486,7 @@ COUNT(*)
...
@@ -3486,7 +3486,7 @@ COUNT(*)
"
"
"Functions (Aggregate)","GROUP_CONCAT","
"Functions (Aggregate)","GROUP_CONCAT","
GROUP_CONCAT ( [ DISTINCT ] string
GROUP_CONCAT ( [ DISTINCT
|ALL
] string
[ ORDER BY { expression [ ASC | DESC ] } [,...] ]
[ ORDER BY { expression [ ASC | DESC ] } [,...] ]
[ SEPARATOR expression ] )
[ SEPARATOR expression ] )
[FILTER (WHERE expression)] [OVER windowNameOrSpecification]
[FILTER (WHERE expression)] [OVER windowNameOrSpecification]
...
@@ -3501,7 +3501,7 @@ GROUP_CONCAT(NAME ORDER BY ID SEPARATOR ', ')
...
@@ -3501,7 +3501,7 @@ GROUP_CONCAT(NAME ORDER BY ID SEPARATOR ', ')
"
"
"Functions (Aggregate)","ARRAY_AGG","
"Functions (Aggregate)","ARRAY_AGG","
ARRAY_AGG ( [ DISTINCT ] string
ARRAY_AGG ( [ DISTINCT
|ALL
] string
[ ORDER BY { expression [ ASC | DESC ] } [,...] ] )
[ ORDER BY { expression [ ASC | DESC ] } [,...] ] )
[FILTER (WHERE expression)] [OVER windowNameOrSpecification]
[FILTER (WHERE expression)] [OVER windowNameOrSpecification]
","
","
...
@@ -3538,7 +3538,7 @@ MIN(NAME)
...
@@ -3538,7 +3538,7 @@ MIN(NAME)
"
"
"Functions (Aggregate)","SUM","
"Functions (Aggregate)","SUM","
SUM( [ DISTINCT ] { numeric } )
SUM( [ DISTINCT
|ALL
] { numeric } )
[FILTER (WHERE expression)] [OVER windowNameOrSpecification]
[FILTER (WHERE expression)] [OVER windowNameOrSpecification]
","
","
The sum of all values.
The sum of all values.
...
@@ -3564,7 +3564,7 @@ SELECT SELECTIVITY(FIRSTNAME), SELECTIVITY(NAME) FROM TEST WHERE ROWNUM()<20000
...
@@ -3564,7 +3564,7 @@ SELECT SELECTIVITY(FIRSTNAME), SELECTIVITY(NAME) FROM TEST WHERE ROWNUM()<20000
"
"
"Functions (Aggregate)","STDDEV_POP","
"Functions (Aggregate)","STDDEV_POP","
STDDEV_POP( [ DISTINCT ] numeric )
STDDEV_POP( [ DISTINCT
|ALL
] numeric )
[FILTER (WHERE expression)] [OVER windowNameOrSpecification]
[FILTER (WHERE expression)] [OVER windowNameOrSpecification]
","
","
The population standard deviation.
The population standard deviation.
...
@@ -3576,7 +3576,7 @@ STDDEV_POP(X)
...
@@ -3576,7 +3576,7 @@ STDDEV_POP(X)
"
"
"Functions (Aggregate)","STDDEV_SAMP","
"Functions (Aggregate)","STDDEV_SAMP","
STDDEV_SAMP( [ DISTINCT ] numeric )
STDDEV_SAMP( [ DISTINCT
|ALL
] numeric )
[FILTER (WHERE expression)] [OVER windowNameOrSpecification]
[FILTER (WHERE expression)] [OVER windowNameOrSpecification]
","
","
The sample standard deviation.
The sample standard deviation.
...
@@ -3588,7 +3588,7 @@ STDDEV(X)
...
@@ -3588,7 +3588,7 @@ STDDEV(X)
"
"
"Functions (Aggregate)","VAR_POP","
"Functions (Aggregate)","VAR_POP","
VAR_POP( [ DISTINCT ] numeric )
VAR_POP( [ DISTINCT
|ALL
] numeric )
[FILTER (WHERE expression)] [OVER windowNameOrSpecification]
[FILTER (WHERE expression)] [OVER windowNameOrSpecification]
","
","
The population variance (square of the population standard deviation).
The population variance (square of the population standard deviation).
...
@@ -3600,7 +3600,7 @@ VAR_POP(X)
...
@@ -3600,7 +3600,7 @@ VAR_POP(X)
"
"
"Functions (Aggregate)","VAR_SAMP","
"Functions (Aggregate)","VAR_SAMP","
VAR_SAMP( [ DISTINCT ] numeric )
VAR_SAMP( [ DISTINCT
|ALL
] numeric )
[FILTER (WHERE expression)] [OVER windowNameOrSpecification]
[FILTER (WHERE expression)] [OVER windowNameOrSpecification]
","
","
The sample variance (square of the sample standard deviation).
The sample variance (square of the sample standard deviation).
...
@@ -3612,7 +3612,7 @@ VAR_SAMP(X)
...
@@ -3612,7 +3612,7 @@ VAR_SAMP(X)
"
"
"Functions (Aggregate)","MEDIAN","
"Functions (Aggregate)","MEDIAN","
MEDIAN( [ DISTINCT ] value )
MEDIAN( [ DISTINCT
|ALL
] value )
[FILTER (WHERE expression)] [OVER windowNameOrSpecification]
[FILTER (WHERE expression)] [OVER windowNameOrSpecification]
","
","
The value separating the higher half of a values from the lower half.
The value separating the higher half of a values from the lower half.
...
...
h2/src/main/org/h2/command/Parser.java
浏览文件 @
9042e61e
...
@@ -2949,7 +2949,7 @@ public class Parser {
...
@@ -2949,7 +2949,7 @@ public class Parser {
if
(
readIf
(
ASTERISK
))
{
if
(
readIf
(
ASTERISK
))
{
r
=
new
Aggregate
(
AggregateType
.
COUNT_ALL
,
null
,
currentSelect
,
false
);
r
=
new
Aggregate
(
AggregateType
.
COUNT_ALL
,
null
,
currentSelect
,
false
);
}
else
{
}
else
{
boolean
distinct
=
read
If
(
DISTINCT
);
boolean
distinct
=
read
DistinctAgg
(
);
Expression
on
=
readExpression
();
Expression
on
=
readExpression
();
if
(
on
instanceof
Wildcard
&&
!
distinct
)
{
if
(
on
instanceof
Wildcard
&&
!
distinct
)
{
// PostgreSQL compatibility: count(t.*)
// PostgreSQL compatibility: count(t.*)
...
@@ -2960,7 +2960,7 @@ public class Parser {
...
@@ -2960,7 +2960,7 @@ public class Parser {
}
}
break
;
break
;
case
GROUP_CONCAT:
{
case
GROUP_CONCAT:
{
boolean
distinct
=
read
If
(
DISTINCT
);
boolean
distinct
=
read
DistinctAgg
(
);
if
(
equalsToken
(
"GROUP_CONCAT"
,
aggregateName
))
{
if
(
equalsToken
(
"GROUP_CONCAT"
,
aggregateName
))
{
r
=
new
Aggregate
(
AggregateType
.
GROUP_CONCAT
,
readExpression
(),
currentSelect
,
distinct
);
r
=
new
Aggregate
(
AggregateType
.
GROUP_CONCAT
,
readExpression
(),
currentSelect
,
distinct
);
if
(
readIf
(
ORDER
))
{
if
(
readIf
(
ORDER
))
{
...
@@ -2985,7 +2985,7 @@ public class Parser {
...
@@ -2985,7 +2985,7 @@ public class Parser {
break
;
break
;
}
}
case
ARRAY_AGG:
{
case
ARRAY_AGG:
{
boolean
distinct
=
read
If
(
DISTINCT
);
boolean
distinct
=
read
DistinctAgg
(
);
r
=
new
Aggregate
(
AggregateType
.
ARRAY_AGG
,
readExpression
(),
currentSelect
,
distinct
);
r
=
new
Aggregate
(
AggregateType
.
ARRAY_AGG
,
readExpression
(),
currentSelect
,
distinct
);
if
(
readIf
(
ORDER
))
{
if
(
readIf
(
ORDER
))
{
read
(
"BY"
);
read
(
"BY"
);
...
@@ -3020,7 +3020,7 @@ public class Parser {
...
@@ -3020,7 +3020,7 @@ public class Parser {
break
;
break
;
}
}
default
:
default
:
boolean
distinct
=
read
If
(
DISTINCT
);
boolean
distinct
=
read
DistinctAgg
(
);
r
=
new
Aggregate
(
aggregateType
,
readExpression
(),
currentSelect
,
distinct
);
r
=
new
Aggregate
(
aggregateType
,
readExpression
(),
currentSelect
,
distinct
);
break
;
break
;
}
}
...
@@ -3078,7 +3078,7 @@ public class Parser {
...
@@ -3078,7 +3078,7 @@ public class Parser {
}
}
private
JavaAggregate
readJavaAggregate
(
UserAggregate
aggregate
)
{
private
JavaAggregate
readJavaAggregate
(
UserAggregate
aggregate
)
{
boolean
distinct
=
read
If
(
DISTINCT
);
boolean
distinct
=
read
DistinctAgg
(
);
ArrayList
<
Expression
>
params
=
Utils
.
newSmallArrayList
();
ArrayList
<
Expression
>
params
=
Utils
.
newSmallArrayList
();
do
{
do
{
params
.
add
(
readExpression
());
params
.
add
(
readExpression
());
...
@@ -3089,6 +3089,14 @@ public class Parser {
...
@@ -3089,6 +3089,14 @@ public class Parser {
return
agg
;
return
agg
;
}
}
private
boolean
readDistinctAgg
()
{
if
(
readIf
(
DISTINCT
))
{
return
true
;
}
readIf
(
ALL
);
return
false
;
}
private
void
readFilterAndOver
(
AbstractAggregate
aggregate
)
{
private
void
readFilterAndOver
(
AbstractAggregate
aggregate
)
{
if
(
readIf
(
"FILTER"
))
{
if
(
readIf
(
"FILTER"
))
{
read
(
OPEN_PAREN
);
read
(
OPEN_PAREN
);
...
...
h2/src/test/org/h2/test/scripts/functions/aggregate/sum.sql
浏览文件 @
9042e61e
...
@@ -26,6 +26,15 @@ select sum(v), sum(v) filter (where v >= 4) from test where v <= 10;
...
@@ -26,6 +26,15 @@ select sum(v), sum(v) filter (where v >= 4) from test where v <= 10;
>
55
49
>
55
49
>
rows
:
1
>
rows
:
1
insert
into
test
values
(
1
),
(
2
),
(
8
);
>
update
count
:
3
select
sum
(
v
),
sum
(
all
v
),
sum
(
distinct
v
)
from
test
;
>
SUM
(
V
)
SUM
(
V
)
SUM
(
DISTINCT
V
)
>
------ ------ ---------------
>
89
89
78
>
rows
:
1
drop
table
test
;
drop
table
test
;
>
ok
>
ok
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论