Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
doujutun3207
flink
提交
6e118d1d
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,发现更多精彩内容 >>
提交
6e118d1d
编写于
11月 02, 2017
作者:
F
Fabian Hueske
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[FLINK-6226] [table] Add tests for UDFs with Byte, Short, and Float arguments.
上级
37df826e
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
65 addition
and
4 deletion
+65
-4
flink-libraries/flink-table/src/test/scala/org/apache/flink/table/expressions/UserDefinedScalarFunctionTest.scala
...ink/table/expressions/UserDefinedScalarFunctionTest.scala
+26
-2
flink-libraries/flink-table/src/test/scala/org/apache/flink/table/expressions/utils/userDefinedScalarFunctions.scala
.../table/expressions/utils/userDefinedScalarFunctions.scala
+6
-0
flink-libraries/flink-table/src/test/scala/org/apache/flink/table/runtime/batch/table/CorrelateITCase.scala
...che/flink/table/runtime/batch/table/CorrelateITCase.scala
+22
-1
flink-libraries/flink-table/src/test/scala/org/apache/flink/table/utils/UserDefinedTableFunctions.scala
.../apache/flink/table/utils/UserDefinedTableFunctions.scala
+11
-1
未找到文件。
flink-libraries/flink-table/src/test/scala/org/apache/flink/table/expressions/UserDefinedScalarFunctionTest.scala
浏览文件 @
6e118d1d
...
@@ -47,6 +47,24 @@ class UserDefinedScalarFunctionTest extends ExpressionTestBase {
...
@@ -47,6 +47,24 @@ class UserDefinedScalarFunctionTest extends ExpressionTestBase {
"Func1(f0)"
,
"Func1(f0)"
,
"43"
)
"43"
)
testAllApis
(
Func1
(
'f11
),
"Func1(f11)"
,
"Func1(f11)"
,
"4"
)
testAllApis
(
Func1
(
'f12
),
"Func1(f12)"
,
"Func1(f12)"
,
"4"
)
testAllApis
(
Func1
(
'f13
),
"Func1(f13)"
,
"Func1(f13)"
,
"4.0"
)
testAllApis
(
testAllApis
(
Func2
(
'f0
,
'f1
,
'f3
),
Func2
(
'f0
,
'f1
,
'f3
),
"Func2(f0, f1, f3)"
,
"Func2(f0, f1, f3)"
,
...
@@ -360,7 +378,7 @@ class UserDefinedScalarFunctionTest extends ExpressionTestBase {
...
@@ -360,7 +378,7 @@ class UserDefinedScalarFunctionTest extends ExpressionTestBase {
// ----------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------
override
def
testData
:
Any
=
{
override
def
testData
:
Any
=
{
val
testData
=
new
Row
(
1
1
)
val
testData
=
new
Row
(
1
4
)
testData
.
setField
(
0
,
42
)
testData
.
setField
(
0
,
42
)
testData
.
setField
(
1
,
"Test"
)
testData
.
setField
(
1
,
"Test"
)
testData
.
setField
(
2
,
null
)
testData
.
setField
(
2
,
null
)
...
@@ -372,6 +390,9 @@ class UserDefinedScalarFunctionTest extends ExpressionTestBase {
...
@@ -372,6 +390,9 @@ class UserDefinedScalarFunctionTest extends ExpressionTestBase {
testData
.
setField
(
8
,
1000L
)
testData
.
setField
(
8
,
1000L
)
testData
.
setField
(
9
,
Seq
(
"Hello"
,
"World"
))
testData
.
setField
(
9
,
Seq
(
"Hello"
,
"World"
))
testData
.
setField
(
10
,
Array
[
Integer
](
1
,
2
,
null
))
testData
.
setField
(
10
,
Array
[
Integer
](
1
,
2
,
null
))
testData
.
setField
(
11
,
3.
toByte
)
testData
.
setField
(
12
,
3.
toShort
)
testData
.
setField
(
13
,
3.
toFloat
)
testData
testData
}
}
...
@@ -387,7 +408,10 @@ class UserDefinedScalarFunctionTest extends ExpressionTestBase {
...
@@ -387,7 +408,10 @@ class UserDefinedScalarFunctionTest extends ExpressionTestBase {
Types
.
INTERVAL_MONTHS
,
Types
.
INTERVAL_MONTHS
,
Types
.
INTERVAL_MILLIS
,
Types
.
INTERVAL_MILLIS
,
TypeInformation
.
of
(
classOf
[
Seq
[
String
]]),
TypeInformation
.
of
(
classOf
[
Seq
[
String
]]),
BasicArrayTypeInfo
.
INT_ARRAY_TYPE_INFO
BasicArrayTypeInfo
.
INT_ARRAY_TYPE_INFO
,
Types
.
BYTE
,
Types
.
SHORT
,
Types
.
FLOAT
).
asInstanceOf
[
TypeInformation
[
Any
]]
).
asInstanceOf
[
TypeInformation
[
Any
]]
}
}
...
...
flink-libraries/flink-table/src/test/scala/org/apache/flink/table/expressions/utils/userDefinedScalarFunctions.scala
浏览文件 @
6e118d1d
...
@@ -41,6 +41,12 @@ object Func1 extends ScalarFunction {
...
@@ -41,6 +41,12 @@ object Func1 extends ScalarFunction {
def
eval
(
index
:
Integer
)
:
Integer
=
{
def
eval
(
index
:
Integer
)
:
Integer
=
{
index
+
1
index
+
1
}
}
def
eval
(
b
:
Byte
)
:
Byte
=
(
b
+
1
).
toByte
def
eval
(
s
:
Short
)
:
Short
=
(
s
+
1
).
toShort
def
eval
(
f
:
Float
)
:
Float
=
f
+
1
}
}
object
Func2
extends
ScalarFunction
{
object
Func2
extends
ScalarFunction
{
...
...
flink-libraries/flink-table/src/test/scala/org/apache/flink/table/runtime/batch/table/CorrelateITCase.scala
浏览文件 @
6e118d1d
...
@@ -22,7 +22,7 @@ import java.sql.{Date, Timestamp}
...
@@ -22,7 +22,7 @@ import java.sql.{Date, Timestamp}
import
org.apache.flink.api.scala._
import
org.apache.flink.api.scala._
import
org.apache.flink.api.scala.util.CollectionDataSets
import
org.apache.flink.api.scala.util.CollectionDataSets
import
org.apache.flink.table.api.
{
TableEnvironment
,
TableException
,
ValidationException
}
import
org.apache.flink.table.api.
{
TableEnvironment
,
TableException
,
Types
,
ValidationException
}
import
org.apache.flink.table.runtime.utils.JavaUserDefinedTableFunctions.JavaTableFunc0
import
org.apache.flink.table.runtime.utils.JavaUserDefinedTableFunctions.JavaTableFunc0
import
org.apache.flink.table.api.scala._
import
org.apache.flink.table.api.scala._
import
org.apache.flink.table.expressions.utils.
{
Func1
,
Func13
,
Func18
,
RichFunc2
}
import
org.apache.flink.table.expressions.utils.
{
Func1
,
Func13
,
Func18
,
RichFunc2
}
...
@@ -230,6 +230,27 @@ class CorrelateITCase(
...
@@ -230,6 +230,27 @@ class CorrelateITCase(
TestBaseUtils
.
compareResultAsText
(
results
.
asJava
,
expected
)
TestBaseUtils
.
compareResultAsText
(
results
.
asJava
,
expected
)
}
}
@Test
def
testByteShortFloatArguments
()
:
Unit
=
{
val
env
=
ExecutionEnvironment
.
getExecutionEnvironment
val
tableEnv
=
TableEnvironment
.
getTableEnvironment
(
env
,
config
)
val
in
=
testData
(
env
).
toTable
(
tableEnv
).
as
(
'a
,
'b
,
'c
)
val
tFunc
=
new
TableFunc4
val
result
=
in
.
select
(
'a
.
cast
(
Types
.
BYTE
)
as
'a
,
'a
.
cast
(
Types
.
SHORT
)
as
'b
,
'b
.
cast
(
Types
.
FLOAT
)
as
'c
)
.
join
(
tFunc
(
'a
,
'b
,
'c
)
as
(
'a2
,
'b2
,
'c2
))
.
toDataSet
[
Row
]
val
results
=
result
.
collect
()
val
expected
=
Seq
(
"1,1,1.0,Byte=1,Short=1,Float=1.0"
,
"2,2,2.0,Byte=2,Short=2,Float=2.0"
,
"3,3,2.0,Byte=3,Short=3,Float=2.0"
,
"4,4,3.0,Byte=4,Short=4,Float=3.0"
).
mkString
(
"\n"
)
TestBaseUtils
.
compareResultAsText
(
results
.
asJava
,
expected
)
}
@Test
@Test
def
testUserDefinedTableFunctionWithParameter
()
:
Unit
=
{
def
testUserDefinedTableFunctionWithParameter
()
:
Unit
=
{
val
env
=
ExecutionEnvironment
.
getExecutionEnvironment
val
env
=
ExecutionEnvironment
.
getExecutionEnvironment
...
...
flink-libraries/flink-table/src/test/scala/org/apache/flink/table/utils/UserDefinedTableFunctions.scala
浏览文件 @
6e118d1d
...
@@ -22,7 +22,7 @@ import java.lang.Boolean
...
@@ -22,7 +22,7 @@ import java.lang.Boolean
import
org.apache.flink.api.common.typeinfo.
{
BasicTypeInfo
,
TypeInformation
}
import
org.apache.flink.api.common.typeinfo.
{
BasicTypeInfo
,
TypeInformation
}
import
org.apache.flink.api.java.tuple.Tuple3
import
org.apache.flink.api.java.tuple.Tuple3
import
org.apache.flink.api.java.typeutils.RowTypeInfo
import
org.apache.flink.api.java.typeutils.RowTypeInfo
import
org.apache.flink.table.api.
ValidationException
import
org.apache.flink.table.api.
{
Types
,
ValidationException
}
import
org.apache.flink.table.functions.
{
FunctionContext
,
TableFunction
}
import
org.apache.flink.table.functions.
{
FunctionContext
,
TableFunction
}
import
org.apache.flink.types.Row
import
org.apache.flink.types.Row
import
org.junit.Assert
import
org.junit.Assert
...
@@ -109,6 +109,16 @@ class TableFunc3(data: String, conf: Map[String, String]) extends TableFunction[
...
@@ -109,6 +109,16 @@ class TableFunc3(data: String, conf: Map[String, String]) extends TableFunction[
}
}
}
}
class
TableFunc4
extends
TableFunction
[
Row
]
{
def
eval
(
b
:
Byte
,
s
:
Short
,
f
:
Float
)
:
Unit
=
{
collect
(
Row
.
of
(
"Byte="
+
b
,
"Short="
+
s
,
"Float="
+
f
))
}
override
def
getResultType
:
TypeInformation
[
Row
]
=
{
new
RowTypeInfo
(
Types
.
STRING
,
Types
.
STRING
,
Types
.
STRING
)
}
}
class
HierarchyTableFunction
extends
SplittableTableFunction
[
Boolean
,
Integer
]
{
class
HierarchyTableFunction
extends
SplittableTableFunction
[
Boolean
,
Integer
]
{
def
eval
(
user
:
String
)
{
def
eval
(
user
:
String
)
{
if
(
user
.
contains
(
"#"
))
{
if
(
user
.
contains
(
"#"
))
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录