Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
doujutun3207
flink
提交
68afd048
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,发现更多精彩内容 >>
未验证
提交
68afd048
编写于
2月 27, 2020
作者:
R
Rui Li
提交者:
GitHub
2月 27, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[FLINK-16275][table-planner-blink] AggsHandlerCodeGenerator can fail with custom module (#11215)
上级
ee0c21e1
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
50 addition
and
1 deletion
+50
-1
flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/codegen/agg/AggsHandlerCodeGenerator.scala
.../table/planner/codegen/agg/AggsHandlerCodeGenerator.scala
+10
-0
flink-table/flink-table-planner-blink/src/test/scala/org/apache/flink/table/planner/runtime/batch/sql/OverWindowITCase.scala
...nk/table/planner/runtime/batch/sql/OverWindowITCase.scala
+33
-1
flink-table/flink-table-planner-blink/src/test/scala/org/apache/flink/table/planner/runtime/utils/UserDefinedFunctionTestUtils.scala
.../planner/runtime/utils/UserDefinedFunctionTestUtils.scala
+7
-0
未找到文件。
flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/codegen/agg/AggsHandlerCodeGenerator.scala
浏览文件 @
68afd048
...
...
@@ -17,6 +17,7 @@
*/
package
org.apache.flink.table.planner.codegen.agg
import
org.apache.flink.api.common.functions.RuntimeContext
import
org.apache.flink.table.api.TableException
import
org.apache.flink.table.dataformat.GenericRow
import
org.apache.flink.table.dataformat.util.BaseRowUtil
...
...
@@ -333,18 +334,27 @@ class AggsHandlerCodeGenerator(
val
functionName
=
newName
(
name
)
val
RUNTIME_CONTEXT
=
className
[
RuntimeContext
]
val
functionCode
=
j
"""
public final class $functionName implements $AGGS_HANDLER_FUNCTION {
${ctx.reuseMemberCode()}
private $STATE_DATA_VIEW_STORE store;
public $functionName(java.lang.Object[] references) throws Exception {
${ctx.reuseInitCode()}
}
private $RUNTIME_CONTEXT getRuntimeContext() {
return store.getRuntimeContext();
}
@Override
public void open($STATE_DATA_VIEW_STORE store) throws Exception {
this.store = store;
${ctx.reuseOpenCode()}
}
...
...
flink-table/flink-table-planner-blink/src/test/scala/org/apache/flink/table/planner/runtime/batch/sql/OverWindowITCase.scala
浏览文件 @
68afd048
...
...
@@ -23,16 +23,19 @@ import org.apache.flink.api.java.tuple.{Tuple1 => JTuple1}
import
org.apache.flink.api.java.typeutils.
{
RowTypeInfo
,
TupleTypeInfo
}
import
org.apache.flink.api.scala._
import
org.apache.flink.table.api.Types
import
org.apache.flink.table.functions.AggregateFunction
import
org.apache.flink.table.functions.
{
AggregateFunction
,
FunctionDefinition
,
ScalarFunctionDefinition
}
import
org.apache.flink.table.module.
{
CoreModule
,
Module
}
import
org.apache.flink.table.planner.runtime.utils.BatchTestBase
import
org.apache.flink.table.planner.runtime.utils.BatchTestBase.row
import
org.apache.flink.table.planner.runtime.utils.TestData._
import
org.apache.flink.table.planner.runtime.utils.UserDefinedFunctionTestUtils.IsNullUDF
import
org.apache.flink.table.planner.utils.DateTimeTestUtil._
import
org.apache.flink.types.Row
import
org.junit.
{
Before
,
Test
}
import
java.lang.
{
Iterable
=>
JIterable
,
Long
=>
JLong
}
import
java.util.
{
Collections
,
Optional
}
import
scala.collection.Seq
import
scala.util.Random
...
...
@@ -2522,6 +2525,20 @@ class OverWindowITCase extends BatchTestBase {
row
(
5
,
14L
,
30
,
1
,
15
,
1
,
1
,
true
,
null
,
false
,
null
),
row
(
5
,
15L
,
30
,
1
,
15
,
1
,
1
,
true
,
null
,
false
,
null
)))
}
@Test
def
testRankWithCustomModule
()
:
Unit
=
{
tEnv
.
unloadModule
(
"core"
)
tEnv
.
loadModule
(
"test-module"
,
new
TestModule
)
tEnv
.
loadModule
(
"core"
,
CoreModule
.
INSTANCE
)
registerCollection
(
"emp"
,
Seq
(
row
(
"1"
,
"A"
,
1
),
row
(
"1"
,
"B"
,
2
),
row
(
"2"
,
"C"
,
3
)),
new
RowTypeInfo
(
STRING_TYPE_INFO
,
STRING_TYPE_INFO
,
INT_TYPE_INFO
),
"dep,name,salary"
)
checkResult
(
"select dep,name,rank() over (partition by dep order by salary desc) as rnk from emp"
,
Seq
(
row
(
"1"
,
"A"
,
2
),
row
(
"1"
,
"B"
,
1
),
row
(
"2"
,
"C"
,
1
)))
}
}
/** The initial accumulator for count aggregate function */
...
...
@@ -2576,3 +2593,18 @@ class CountAggFunction extends AggregateFunction[JLong, CountAccumulator] {
override
def
getResultType
:
TypeInformation
[
JLong
]
=
Types
.
LONG
}
private
class
TestModule
extends
Module
{
private
val
funcName
=
"isnull"
override
def
listFunctions
()
:
java.util.Set
[
String
]
=
Collections
.
singleton
(
funcName
)
override
def
getFunctionDefinition
(
name
:
String
)
:
Optional
[
FunctionDefinition
]
=
{
if
(
name
.
equalsIgnoreCase
(
funcName
))
{
Optional
.
of
(
new
ScalarFunctionDefinition
(
name
,
IsNullUDF
))
}
else
{
Optional
.
empty
()
}
}
}
flink-table/flink-table-planner-blink/src/test/scala/org/apache/flink/table/planner/runtime/utils/UserDefinedFunctionTestUtils.scala
浏览文件 @
68afd048
...
...
@@ -377,6 +377,13 @@ object UserDefinedFunctionTestUtils {
override
def
getResultType
(
signature
:
Array
[
Class
[
_
]])
:
TypeInformation
[
_
]
=
Types
.
JAVA_BIG_DEC
}
@SerialVersionUID
(
1L
)
object
IsNullUDF
extends
ScalarFunction
{
def
eval
(
v
:
Any
)
:
Boolean
=
v
==
null
override
def
getResultType
(
signature
:
Array
[
Class
[
_
]])
:
TypeInformation
[
_
]
=
Types
.
BOOLEAN
}
// ------------------------------------------------------------------------------------
// POJOs
// ------------------------------------------------------------------------------------
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录