Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
doujutun3207
flink
提交
20fe2af8
F
flink
项目概览
doujutun3207
/
flink
与 Fork 源项目一致
从无法访问的项目Fork
通知
24
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
flink
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
20fe2af8
编写于
12月 01, 2015
作者:
C
chengxiang li
提交者:
Aljoscha Krettek
12月 02, 2015
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[FLINK-3087] [Table API] support multi count in aggregation.
上级
9215b724
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
48 addition
and
8 deletion
+48
-8
flink-staging/flink-table/src/main/scala/org/apache/flink/api/table/codegen/ExpressionCodeGenerator.scala
...che/flink/api/table/codegen/ExpressionCodeGenerator.scala
+9
-6
flink-staging/flink-table/src/main/scala/org/apache/flink/api/table/plan/ExpandAggregations.scala
.../org/apache/flink/api/table/plan/ExpandAggregations.scala
+5
-2
flink-staging/flink-table/src/test/java/org/apache/flink/api/java/table/test/AggregationsITCase.java
.../apache/flink/api/java/table/test/AggregationsITCase.java
+23
-0
flink-staging/flink-table/src/test/scala/org/apache/flink/api/scala/table/test/AggregationsITCase.scala
...pache/flink/api/scala/table/test/AggregationsITCase.scala
+11
-0
未找到文件。
flink-staging/flink-table/src/main/scala/org/apache/flink/api/table/codegen/ExpressionCodeGenerator.scala
浏览文件 @
20fe2af8
...
...
@@ -123,14 +123,17 @@ abstract class ExpressionCodeGenerator[R](
}
}
val
cleanedExpr
=
expr
match
{
case
expressions
.
Naming
(
namedExpr
,
_
)
=>
namedExpr
case
_
=>
expr
def
cleanedExpr
(
e
:
Expression
)
:
Expression
=
{
e
match
{
case
expressions
.
Naming
(
namedExpr
,
_
)
=>
cleanedExpr
(
namedExpr
)
case
_
=>
e
}
}
val
resultTpe
=
typeTermForTypeInfo
(
cleanedExpr
.
typeInfo
)
val
code
:
String
=
cleanedExpr
match
{
val
cleanedExpression
=
cleanedExpr
(
expr
)
val
resultTpe
=
typeTermForTypeInfo
(
cleanedExpression
.
typeInfo
)
val
code
:
String
=
cleanedExpression
match
{
case
expressions
.
Literal
(
null
,
typeInfo
)
=>
if
(
nullCheck
)
{
...
...
flink-staging/flink-table/src/main/scala/org/apache/flink/api/table/plan/ExpandAggregations.scala
浏览文件 @
20fe2af8
...
...
@@ -51,20 +51,23 @@ object ExpandAggregations {
val
aggregationIntermediates
=
mutable
.
HashMap
[
Aggregation
,
Seq
[
Expression
]]()
var
intermediateCount
=
0
var
resultCount
=
0
selection
foreach
{
f
=>
f
.
transformPre
{
case
agg
:
Aggregation
=>
val
intermediateReferences
=
agg
.
getIntermediateFields
.
zip
(
agg
.
getAggregations
)
map
{
case
(
expr
,
basicAgg
)
=>
resultCount
+=
1
val
resultName
=
s
"result.$resultCount"
aggregations
.
get
((
expr
,
basicAgg
))
match
{
case
Some
(
intermediateName
)
=>
ResolvedFieldReference
(
intermediateName
,
expr
.
typeInfo
)
Naming
(
ResolvedFieldReference
(
intermediateName
,
expr
.
typeInfo
),
resultName
)
case
None
=>
intermediateCount
=
intermediateCount
+
1
val
intermediateName
=
s
"intermediate.$intermediateCount"
intermediateFields
+=
Naming
(
expr
,
intermediateName
)
aggregations
((
expr
,
basicAgg
))
=
intermediateName
ResolvedFieldReference
(
intermediateName
,
expr
.
typeInfo
)
Naming
(
ResolvedFieldReference
(
intermediateName
,
expr
.
typeInfo
),
resultName
)
}
}
...
...
flink-staging/flink-table/src/test/java/org/apache/flink/api/java/table/test/AggregationsITCase.java
浏览文件 @
20fe2af8
...
...
@@ -137,6 +137,29 @@ public class AggregationsITCase extends MultipleProgramsTestBase {
compareResultAsText
(
results
,
expected
);
}
@Test
public
void
testAggregationWithTwoCount
()
throws
Exception
{
ExecutionEnvironment
env
=
ExecutionEnvironment
.
getExecutionEnvironment
();
TableEnvironment
tableEnv
=
new
TableEnvironment
();
DataSource
<
Tuple2
<
Float
,
String
>>
input
=
env
.
fromElements
(
new
Tuple2
<>(
1
f
,
"Hello"
),
new
Tuple2
<>(
2
f
,
"Ciao"
));
Table
table
=
tableEnv
.
fromDataSet
(
input
);
Table
result
=
table
.
select
(
"f0.count, f1.count"
);
DataSet
<
Row
>
ds
=
tableEnv
.
toDataSet
(
result
,
Row
.
class
);
List
<
Row
>
results
=
ds
.
collect
();
String
expected
=
"2,2"
;
compareResultAsText
(
results
,
expected
);
}
@Test
(
expected
=
ExpressionException
.
class
)
public
void
testNonWorkingDataTypes
()
throws
Exception
{
ExecutionEnvironment
env
=
ExecutionEnvironment
.
getExecutionEnvironment
();
...
...
flink-staging/flink-table/src/test/scala/org/apache/flink/api/scala/table/test/AggregationsITCase.scala
浏览文件 @
20fe2af8
...
...
@@ -80,6 +80,17 @@ class AggregationsITCase(mode: TestExecutionMode) extends MultipleProgramsTestBa
TestBaseUtils
.
compareResultAsText
(
results
.
asJava
,
expected
)
}
@Test
def
testAggregationWithTwoCount
()
:
Unit
=
{
val
env
=
ExecutionEnvironment
.
getExecutionEnvironment
val
ds
=
env
.
fromElements
((
1f
,
"Hello"
),
(
2f
,
"Ciao"
)).
toTable
.
select
(
'_1
.
count
,
'_2
.
count
).
toDataSet
[
Row
]
val
expected
=
"2,2"
val
results
=
ds
.
collect
()
TestBaseUtils
.
compareResultAsText
(
results
.
asJava
,
expected
)
}
@Test
(
expected
=
classOf
[
ExpressionException
])
def
testNonWorkingAggregationDataTypes
()
:
Unit
=
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录