Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
doujutun3207
flink
提交
b3c86a81
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,发现更多精彩内容 >>
未验证
提交
b3c86a81
编写于
2月 04, 2020
作者:
D
Dawid Wysakowicz
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[FLINK-15706][table-planner-blink] Reorder and split into sections classes in aggfunctions tests.
上级
e0afec8a
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
922 addition
and
799 deletion
+922
-799
flink-table/flink-table-planner-blink/src/test/java/org/apache/flink/table/planner/functions/aggfunctions/FirstValueAggFunctionWithOrderTest.java
...ions/aggfunctions/FirstValueAggFunctionWithOrderTest.java
+99
-93
flink-table/flink-table-planner-blink/src/test/java/org/apache/flink/table/planner/functions/aggfunctions/FirstValueAggFunctionWithoutOrderTest.java
...s/aggfunctions/FirstValueAggFunctionWithoutOrderTest.java
+76
-62
flink-table/flink-table-planner-blink/src/test/java/org/apache/flink/table/planner/functions/aggfunctions/FirstValueWithRetractAggFunctionWithOrderTest.java
...ctions/FirstValueWithRetractAggFunctionWithOrderTest.java
+107
-94
flink-table/flink-table-planner-blink/src/test/java/org/apache/flink/table/planner/functions/aggfunctions/FirstValueWithRetractAggFunctionWithoutOrderTest.java
...ons/FirstValueWithRetractAggFunctionWithoutOrderTest.java
+83
-68
flink-table/flink-table-planner-blink/src/test/java/org/apache/flink/table/planner/functions/aggfunctions/LastValueAggFunctionWithOrderTest.java
...tions/aggfunctions/LastValueAggFunctionWithOrderTest.java
+97
-93
flink-table/flink-table-planner-blink/src/test/java/org/apache/flink/table/planner/functions/aggfunctions/LastValueAggFunctionWithoutOrderTest.java
...ns/aggfunctions/LastValueAggFunctionWithoutOrderTest.java
+75
-63
flink-table/flink-table-planner-blink/src/test/java/org/apache/flink/table/planner/functions/aggfunctions/LastValueWithRetractAggFunctionWithOrderTest.java
...nctions/LastValueWithRetractAggFunctionWithOrderTest.java
+108
-94
flink-table/flink-table-planner-blink/src/test/java/org/apache/flink/table/planner/functions/aggfunctions/LastValueWithRetractAggFunctionWithoutOrderTest.java
...ions/LastValueWithRetractAggFunctionWithoutOrderTest.java
+83
-68
flink-table/flink-table-planner-blink/src/test/java/org/apache/flink/table/planner/functions/aggfunctions/ListAggWithRetractAggFunctionTest.java
...tions/aggfunctions/ListAggWithRetractAggFunctionTest.java
+1
-1
flink-table/flink-table-planner-blink/src/test/java/org/apache/flink/table/planner/functions/aggfunctions/ListAggWsWithRetractAggFunctionTest.java
...ons/aggfunctions/ListAggWsWithRetractAggFunctionTest.java
+1
-1
flink-table/flink-table-planner-blink/src/test/java/org/apache/flink/table/planner/functions/aggfunctions/MaxWithRetractAggFunctionTest.java
...functions/aggfunctions/MaxWithRetractAggFunctionTest.java
+96
-81
flink-table/flink-table-planner-blink/src/test/java/org/apache/flink/table/planner/functions/aggfunctions/MinWithRetractAggFunctionTest.java
...functions/aggfunctions/MinWithRetractAggFunctionTest.java
+96
-81
未找到文件。
flink-table/flink-table-planner-blink/src/test/java/org/apache/flink/table/planner/functions/aggfunctions/FirstValueAggFunctionWithOrderTest.java
浏览文件 @
b3c86a81
...
...
@@ -44,93 +44,20 @@ import java.util.List;
* This class tests `accumulate` method with order argument.
*/
@RunWith
(
Enclosed
.
class
)
public
class
FirstValueAggFunctionWithOrderTest
{
public
final
class
FirstValueAggFunctionWithOrderTest
{
/**
* The base test class for FirstValueAggFunction with order.
*/
public
abstract
static
class
FirstValueAggFunctionWithOrderTestBase
<
T
>
extends
FirstLastValueAggFunctionWithOrderTestBase
<
T
>
{
}
/**
* Test FirstValueAggFunction for number type.
*/
public
abstract
static
class
NumberFirstValueAggFunctionWithOrderTestBase
<
T
>
extends
FirstValueAggFunctionWithOrderTestBase
<
T
>
{
protected
abstract
T
getValue
(
String
v
);
@Override
protected
List
<
List
<
T
>>
getInputValueSets
()
{
return
Arrays
.
asList
(
Arrays
.
asList
(
getValue
(
"1"
),
null
,
getValue
(
"-99"
),
getValue
(
"3"
),
null
,
getValue
(
"3"
),
getValue
(
"2"
),
getValue
(
"-99"
)
),
Arrays
.
asList
(
null
,
null
,
null
,
null
),
Arrays
.
asList
(
null
,
getValue
(
"10"
),
null
,
getValue
(
"5"
)
)
);
}
@Override
protected
List
<
List
<
Long
>>
getInputOrderSets
()
{
return
Arrays
.
asList
(
Arrays
.
asList
(
10L
,
2L
,
5L
,
6L
,
11L
,
3L
,
7L
,
5L
),
Arrays
.
asList
(
8L
,
6L
,
9L
,
5L
),
Arrays
.
asList
(
null
,
6L
,
4L
,
3L
)
);
}
@Override
protected
List
<
T
>
getExpectedResults
()
{
return
Arrays
.
asList
(
getValue
(
"3"
),
null
,
getValue
(
"5"
)
);
}
}
// --------------------------------------------------------------------------------------------
// Test sets for a particular type being aggregated
//
// Actual tests are implemented in:
// - FirstLastValueAggFunctionWithOrderTestBase -> tests specific for FirstValue and LastValue
// - AggFunctionTestBase -> tests that apply to all aggregate functions
// --------------------------------------------------------------------------------------------
/**
* Test for ByteFirstValueAggFunction.
*/
public
static
class
ByteFirstValueAggFunctionWithOrderTest
public
static
final
class
ByteFirstValueAggFunctionWithOrderTest
extends
NumberFirstValueAggFunctionWithOrderTestBase
<
Byte
>
{
@Override
...
...
@@ -147,7 +74,7 @@ public class FirstValueAggFunctionWithOrderTest {
/**
* Test for ShortFirstValueAggFunction.
*/
public
static
class
ShortFirstValueAggFunctionWithOrderTest
public
static
final
class
ShortFirstValueAggFunctionWithOrderTest
extends
NumberFirstValueAggFunctionWithOrderTestBase
<
Short
>
{
@Override
...
...
@@ -164,7 +91,7 @@ public class FirstValueAggFunctionWithOrderTest {
/**
* Test for IntFirstValueAggFunction.
*/
public
static
class
IntFirstValueAggFunctionWithOrderTest
public
static
final
class
IntFirstValueAggFunctionWithOrderTest
extends
NumberFirstValueAggFunctionWithOrderTestBase
<
Integer
>
{
@Override
...
...
@@ -181,7 +108,7 @@ public class FirstValueAggFunctionWithOrderTest {
/**
* Test for LongFirstValueAggFunction.
*/
public
static
class
LongFirstValueAggFunctionWithOrderTest
public
static
final
class
LongFirstValueAggFunctionWithOrderTest
extends
NumberFirstValueAggFunctionWithOrderTestBase
<
Long
>
{
@Override
...
...
@@ -198,7 +125,7 @@ public class FirstValueAggFunctionWithOrderTest {
/**
* Test for FloatFirstValueAggFunction.
*/
public
static
class
FloatFirstValueAggFunctionWithOrderTest
public
static
final
class
FloatFirstValueAggFunctionWithOrderTest
extends
NumberFirstValueAggFunctionWithOrderTestBase
<
Float
>
{
@Override
...
...
@@ -215,7 +142,7 @@ public class FirstValueAggFunctionWithOrderTest {
/**
* Test for DoubleFirstValueAggFunction.
*/
public
static
class
DoubleFirstValueAggFunctionWithOrderTest
public
static
final
class
DoubleFirstValueAggFunctionWithOrderTest
extends
NumberFirstValueAggFunctionWithOrderTestBase
<
Double
>
{
@Override
...
...
@@ -232,8 +159,8 @@ public class FirstValueAggFunctionWithOrderTest {
/**
* Test for BooleanFirstValueAggFunction.
*/
public
static
class
BooleanFirstValueAggFunctionWithOrderTest
extends
FirstValueAggFunctionWithOrderTestBase
<
Boolean
>
{
public
static
final
class
BooleanFirstValueAggFunctionWithOrderTest
extends
First
Last
ValueAggFunctionWithOrderTestBase
<
Boolean
>
{
@Override
protected
List
<
List
<
Boolean
>>
getInputValueSets
()
{
...
...
@@ -322,8 +249,8 @@ public class FirstValueAggFunctionWithOrderTest {
/**
* Test for DecimalFirstValueAggFunction.
*/
public
static
class
DecimalFirstValueAggFunctionWithOrderTest
extends
FirstValueAggFunctionWithOrderTestBase
<
Decimal
>
{
public
static
final
class
DecimalFirstValueAggFunctionWithOrderTest
extends
First
Last
ValueAggFunctionWithOrderTestBase
<
Decimal
>
{
private
int
precision
=
20
;
private
int
scale
=
6
;
...
...
@@ -402,8 +329,8 @@ public class FirstValueAggFunctionWithOrderTest {
/**
* Test for StringFirstValueAggFunction.
*/
public
static
class
StringFirstValueAggFunctionWithOrderTest
extends
FirstValueAggFunctionWithOrderTestBase
<
BinaryString
>
{
public
static
final
class
StringFirstValueAggFunctionWithOrderTest
extends
First
Last
ValueAggFunctionWithOrderTestBase
<
BinaryString
>
{
@Override
protected
List
<
List
<
BinaryString
>>
getInputValueSets
()
{
...
...
@@ -476,4 +403,83 @@ public class FirstValueAggFunctionWithOrderTest {
return
new
StringFirstValueAggFunction
();
}
}
// --------------------------------------------------------------------------------------------
// This section contain base classes that provide:
// - common inputs
// for tests declared above.
// --------------------------------------------------------------------------------------------
/**
* Test FirstValueAggFunction for number type.
*/
public
abstract
static
class
NumberFirstValueAggFunctionWithOrderTestBase
<
T
>
extends
FirstLastValueAggFunctionWithOrderTestBase
<
T
>
{
protected
abstract
T
getValue
(
String
v
);
@Override
protected
List
<
List
<
T
>>
getInputValueSets
()
{
return
Arrays
.
asList
(
Arrays
.
asList
(
getValue
(
"1"
),
null
,
getValue
(
"-99"
),
getValue
(
"3"
),
null
,
getValue
(
"3"
),
getValue
(
"2"
),
getValue
(
"-99"
)
),
Arrays
.
asList
(
null
,
null
,
null
,
null
),
Arrays
.
asList
(
null
,
getValue
(
"10"
),
null
,
getValue
(
"5"
)
)
);
}
@Override
protected
List
<
List
<
Long
>>
getInputOrderSets
()
{
return
Arrays
.
asList
(
Arrays
.
asList
(
10L
,
2L
,
5L
,
6L
,
11L
,
3L
,
7L
,
5L
),
Arrays
.
asList
(
8L
,
6L
,
9L
,
5L
),
Arrays
.
asList
(
null
,
6L
,
4L
,
3L
)
);
}
@Override
protected
List
<
T
>
getExpectedResults
()
{
return
Arrays
.
asList
(
getValue
(
"3"
),
null
,
getValue
(
"5"
)
);
}
}
}
flink-table/flink-table-planner-blink/src/test/java/org/apache/flink/table/planner/functions/aggfunctions/FirstValueAggFunctionWithoutOrderTest.java
浏览文件 @
b3c86a81
...
...
@@ -44,65 +44,19 @@ import java.util.List;
* This class tests `accumulate` method without order argument.
*/
@RunWith
(
Enclosed
.
class
)
public
class
FirstValueAggFunctionWithoutOrderTest
{
public
final
class
FirstValueAggFunctionWithoutOrderTest
{
/**
* The base test class for FirstValueAggFunction without order.
*/
public
abstract
static
class
FirstValueAggFunctionWithoutOrderTestBase
<
T
>
extends
AggFunctionTestBase
<
T
,
GenericRow
>
{
@Override
protected
Class
<?>
getAccClass
()
{
return
GenericRow
.
class
;
}
}
/**
* Test FirstValueAggFunction for number type.
*/
public
abstract
static
class
NumberFirstValueAggFunctionWithoutOrderTest
<
T
>
extends
FirstValueAggFunctionWithoutOrderTestBase
<
T
>
{
protected
abstract
T
getValue
(
String
v
);
@Override
protected
List
<
List
<
T
>>
getInputValueSets
()
{
return
Arrays
.
asList
(
Arrays
.
asList
(
getValue
(
"1"
),
null
,
getValue
(
"-99"
),
getValue
(
"3"
),
null
),
Arrays
.
asList
(
null
,
null
,
null
,
null
),
Arrays
.
asList
(
null
,
getValue
(
"10"
),
null
,
getValue
(
"3"
)
)
);
}
@Override
protected
List
<
T
>
getExpectedResults
()
{
return
Arrays
.
asList
(
getValue
(
"1"
),
null
,
getValue
(
"10"
)
);
}
}
// --------------------------------------------------------------------------------------------
// Test sets for a particular type being aggregated
//
// Actual tests are implemented in:
// - AggFunctionTestBase
// --------------------------------------------------------------------------------------------
/**
* Test for ByteFirstValueAggFunction.
*/
public
static
class
ByteFirstValueAggFunctionWithoutOrderTest
public
static
final
class
ByteFirstValueAggFunctionWithoutOrderTest
extends
NumberFirstValueAggFunctionWithoutOrderTest
<
Byte
>
{
@Override
...
...
@@ -119,7 +73,7 @@ public class FirstValueAggFunctionWithoutOrderTest {
/**
* Test for ShortFirstValueAggFunction.
*/
public
static
class
ShortFirstValueAggFunctionWithoutOrderTest
public
static
final
class
ShortFirstValueAggFunctionWithoutOrderTest
extends
NumberFirstValueAggFunctionWithoutOrderTest
<
Short
>
{
@Override
...
...
@@ -136,7 +90,7 @@ public class FirstValueAggFunctionWithoutOrderTest {
/**
* Test for IntFirstValueAggFunction.
*/
public
static
class
IntFirstValueAggFunctionWithoutOrderTest
public
static
final
class
IntFirstValueAggFunctionWithoutOrderTest
extends
NumberFirstValueAggFunctionWithoutOrderTest
<
Integer
>
{
@Override
...
...
@@ -153,7 +107,7 @@ public class FirstValueAggFunctionWithoutOrderTest {
/**
* Test for LongFirstValueAggFunction.
*/
public
static
class
LongFirstValueAggFunctionWithoutOrderTest
public
static
final
class
LongFirstValueAggFunctionWithoutOrderTest
extends
NumberFirstValueAggFunctionWithoutOrderTest
<
Long
>
{
@Override
...
...
@@ -170,7 +124,7 @@ public class FirstValueAggFunctionWithoutOrderTest {
/**
* Test for FloatFirstValueAggFunction.
*/
public
static
class
FloatFirstValueAggFunctionWithoutOrderTest
public
static
final
class
FloatFirstValueAggFunctionWithoutOrderTest
extends
NumberFirstValueAggFunctionWithoutOrderTest
<
Float
>
{
@Override
...
...
@@ -187,7 +141,7 @@ public class FirstValueAggFunctionWithoutOrderTest {
/**
* Test for DoubleFirstValueAggFunction.
*/
public
static
class
DoubleFirstValueAggFunctionWithoutOrderTest
public
static
final
class
DoubleFirstValueAggFunctionWithoutOrderTest
extends
NumberFirstValueAggFunctionWithoutOrderTest
<
Double
>
{
@Override
...
...
@@ -204,7 +158,7 @@ public class FirstValueAggFunctionWithoutOrderTest {
/**
* Test for BooleanFirstValueAggFunction.
*/
public
static
class
BooleanFirstValueAggFunctionWithoutOrderTest
extends
public
static
final
class
BooleanFirstValueAggFunctionWithoutOrderTest
extends
FirstValueAggFunctionWithoutOrderTestBase
<
Boolean
>
{
@Override
...
...
@@ -260,7 +214,7 @@ public class FirstValueAggFunctionWithoutOrderTest {
/**
* Test for DecimalFirstValueAggFunction.
*/
public
static
class
DecimalFirstValueAggFunctionWithoutOrderTest
extends
public
static
final
class
DecimalFirstValueAggFunctionWithoutOrderTest
extends
FirstValueAggFunctionWithoutOrderTestBase
<
Decimal
>
{
private
int
precision
=
20
;
...
...
@@ -312,7 +266,7 @@ public class FirstValueAggFunctionWithoutOrderTest {
/**
* Test for StringFirstValueAggFunction.
*/
public
static
class
StringFirstValueAggFunctionWithoutOrderTest
extends
public
static
final
class
StringFirstValueAggFunctionWithoutOrderTest
extends
FirstValueAggFunctionWithoutOrderTestBase
<
BinaryString
>
{
@Override
...
...
@@ -358,4 +312,64 @@ public class FirstValueAggFunctionWithoutOrderTest {
return
new
StringFirstValueAggFunction
();
}
}
// --------------------------------------------------------------------------------------------
// This section contain base classes that provide:
// - common inputs
// - accumulator class
// for tests declared above.
// --------------------------------------------------------------------------------------------
/**
* The base test class for FirstValueAggFunction without order.
*/
public
abstract
static
class
FirstValueAggFunctionWithoutOrderTestBase
<
T
>
extends
AggFunctionTestBase
<
T
,
GenericRow
>
{
@Override
protected
Class
<?>
getAccClass
()
{
return
GenericRow
.
class
;
}
}
/**
* Test FirstValueAggFunction for number type.
*/
public
abstract
static
class
NumberFirstValueAggFunctionWithoutOrderTest
<
T
>
extends
FirstValueAggFunctionWithoutOrderTestBase
<
T
>
{
protected
abstract
T
getValue
(
String
v
);
@Override
protected
List
<
List
<
T
>>
getInputValueSets
()
{
return
Arrays
.
asList
(
Arrays
.
asList
(
getValue
(
"1"
),
null
,
getValue
(
"-99"
),
getValue
(
"3"
),
null
),
Arrays
.
asList
(
null
,
null
,
null
,
null
),
Arrays
.
asList
(
null
,
getValue
(
"10"
),
null
,
getValue
(
"3"
)
)
);
}
@Override
protected
List
<
T
>
getExpectedResults
()
{
return
Arrays
.
asList
(
getValue
(
"1"
),
null
,
getValue
(
"10"
)
);
}
}
}
flink-table/flink-table-planner-blink/src/test/java/org/apache/flink/table/planner/functions/aggfunctions/FirstValueWithRetractAggFunctionWithOrderTest.java
浏览文件 @
b3c86a81
...
...
@@ -45,97 +45,20 @@ import java.util.List;
* This class tests `accumulate` method with order argument.
*/
@RunWith
(
Enclosed
.
class
)
public
class
FirstValueWithRetractAggFunctionWithOrderTest
{
public
final
class
FirstValueWithRetractAggFunctionWithOrderTest
{
/**
* The base test class for FirstValueWithRetractAggFunction with order.
*/
public
abstract
static
class
FirstValueWithRetractAggFunctionWithOrderTestBase
<
T
>
extends
FirstLastValueAggFunctionWithOrderTestBase
<
T
>
{
@Override
protected
Method
getRetractFunc
()
throws
NoSuchMethodException
{
return
getAggregator
().
getClass
().
getMethod
(
"retract"
,
getAccClass
(),
Object
.
class
,
Long
.
class
);
}
}
/**
* Test FirstValueWithRetractAggFunction for number type.
*/
public
abstract
static
class
NumberFirstValueWithRetractAggFunctionWithOrderTestBase
<
T
>
extends
FirstValueWithRetractAggFunctionWithOrderTestBase
<
T
>
{
protected
abstract
T
getValue
(
String
v
);
@Override
protected
List
<
List
<
T
>>
getInputValueSets
()
{
return
Arrays
.
asList
(
Arrays
.
asList
(
getValue
(
"1"
),
null
,
getValue
(
"-99"
),
getValue
(
"3"
),
null
,
getValue
(
"3"
),
getValue
(
"2"
),
getValue
(
"-99"
)
),
Arrays
.
asList
(
null
,
null
,
null
,
null
),
Arrays
.
asList
(
null
,
getValue
(
"10"
),
null
,
getValue
(
"5"
)
)
);
}
@Override
protected
List
<
List
<
Long
>>
getInputOrderSets
()
{
return
Arrays
.
asList
(
Arrays
.
asList
(
10L
,
2L
,
5L
,
6L
,
11L
,
3L
,
7L
,
5L
),
Arrays
.
asList
(
8L
,
6L
,
9L
,
5L
),
Arrays
.
asList
(
null
,
6L
,
4L
,
3L
)
);
}
@Override
protected
List
<
T
>
getExpectedResults
()
{
return
Arrays
.
asList
(
getValue
(
"3"
),
null
,
getValue
(
"5"
)
);
}
}
// --------------------------------------------------------------------------------------------
// Test sets for a particular type being aggregated
//
// Actual tests are implemented in:
// - FirstLastValueAggFunctionWithOrderTestBase -> tests specific for FirstValue and LastValue
// - AggFunctionTestBase -> tests that apply to all aggregate functions
// --------------------------------------------------------------------------------------------
/**
* Test for ByteFirstValueWithRetractAggFunction.
*/
public
static
class
ByteFirstValueWithRetractAggFunctionWithOrderTest
public
static
final
class
ByteFirstValueWithRetractAggFunctionWithOrderTest
extends
NumberFirstValueWithRetractAggFunctionWithOrderTestBase
<
Byte
>
{
@Override
...
...
@@ -152,7 +75,7 @@ public class FirstValueWithRetractAggFunctionWithOrderTest {
/**
* Test for ShortFirstValueWithRetractAggFunction.
*/
public
static
class
ShortFirstValueWithRetractAggFunctionWithOrderTest
public
static
final
class
ShortFirstValueWithRetractAggFunctionWithOrderTest
extends
NumberFirstValueWithRetractAggFunctionWithOrderTestBase
<
Short
>
{
@Override
...
...
@@ -169,7 +92,7 @@ public class FirstValueWithRetractAggFunctionWithOrderTest {
/**
* Test for IntFirstValueWithRetractAggFunction.
*/
public
static
class
IntFirstValueWithRetractAggFunctionWithOrderTest
public
static
final
class
IntFirstValueWithRetractAggFunctionWithOrderTest
extends
NumberFirstValueWithRetractAggFunctionWithOrderTestBase
<
Integer
>
{
@Override
...
...
@@ -186,7 +109,7 @@ public class FirstValueWithRetractAggFunctionWithOrderTest {
/**
* Test for LongFirstValueWithRetractAggFunction.
*/
public
static
class
LongFirstValueWithRetractAggFunctionWithOrderTest
public
static
final
class
LongFirstValueWithRetractAggFunctionWithOrderTest
extends
NumberFirstValueWithRetractAggFunctionWithOrderTestBase
<
Long
>
{
@Override
...
...
@@ -203,7 +126,7 @@ public class FirstValueWithRetractAggFunctionWithOrderTest {
/**
* Test for FloatFirstValueWithRetractAggFunction.
*/
public
static
class
FloatFirstValueWithRetractAggFunctionWithOrderTest
public
static
final
class
FloatFirstValueWithRetractAggFunctionWithOrderTest
extends
NumberFirstValueWithRetractAggFunctionWithOrderTestBase
<
Float
>
{
@Override
...
...
@@ -220,7 +143,7 @@ public class FirstValueWithRetractAggFunctionWithOrderTest {
/**
* Test for DoubleFirstValueWithRetractAggFunction.
*/
public
static
class
DoubleFirstValueWithRetractAggFunctionWithOrderTest
public
static
final
class
DoubleFirstValueWithRetractAggFunctionWithOrderTest
extends
NumberFirstValueWithRetractAggFunctionWithOrderTestBase
<
Double
>
{
@Override
...
...
@@ -237,7 +160,7 @@ public class FirstValueWithRetractAggFunctionWithOrderTest {
/**
* Test for BooleanFirstValueWithRetractAggFunction.
*/
public
static
class
BooleanFirstValueWithRetractAggFunctionWithOrderTest
public
static
final
class
BooleanFirstValueWithRetractAggFunctionWithOrderTest
extends
FirstValueWithRetractAggFunctionWithOrderTestBase
<
Boolean
>
{
@Override
...
...
@@ -327,7 +250,7 @@ public class FirstValueWithRetractAggFunctionWithOrderTest {
/**
* Test for DecimalFirstValueWithRetractAggFunction.
*/
public
static
class
DecimalFirstValueWithRetractAggFunctionWithOrderTest
public
static
final
class
DecimalFirstValueWithRetractAggFunctionWithOrderTest
extends
FirstValueWithRetractAggFunctionWithOrderTestBase
<
Decimal
>
{
private
int
precision
=
20
;
...
...
@@ -407,7 +330,7 @@ public class FirstValueWithRetractAggFunctionWithOrderTest {
/**
* Test for StringFirstValueWithRetractAggFunction.
*/
public
static
class
StringFirstValueWithRetractAggFunctionWithOrderTest
public
static
final
class
StringFirstValueWithRetractAggFunctionWithOrderTest
extends
FirstValueWithRetractAggFunctionWithOrderTestBase
<
BinaryString
>
{
@Override
...
...
@@ -481,4 +404,94 @@ public class FirstValueWithRetractAggFunctionWithOrderTest {
return
new
StringFirstValueWithRetractAggFunction
();
}
}
/**
* The base test class for FirstValueWithRetractAggFunction with order.
*/
public
abstract
static
class
FirstValueWithRetractAggFunctionWithOrderTestBase
<
T
>
extends
FirstLastValueAggFunctionWithOrderTestBase
<
T
>
{
@Override
protected
Method
getRetractFunc
()
throws
NoSuchMethodException
{
return
getAggregator
().
getClass
().
getMethod
(
"retract"
,
getAccClass
(),
Object
.
class
,
Long
.
class
);
}
}
// --------------------------------------------------------------------------------------------
// This section contain base classes that provide common inputs for tests declared above.
// --------------------------------------------------------------------------------------------
/**
* Test FirstValueWithRetractAggFunction for number type.
*/
public
abstract
static
class
NumberFirstValueWithRetractAggFunctionWithOrderTestBase
<
T
>
extends
FirstValueWithRetractAggFunctionWithOrderTestBase
<
T
>
{
protected
abstract
T
getValue
(
String
v
);
@Override
protected
List
<
List
<
T
>>
getInputValueSets
()
{
return
Arrays
.
asList
(
Arrays
.
asList
(
getValue
(
"1"
),
null
,
getValue
(
"-99"
),
getValue
(
"3"
),
null
,
getValue
(
"3"
),
getValue
(
"2"
),
getValue
(
"-99"
)
),
Arrays
.
asList
(
null
,
null
,
null
,
null
),
Arrays
.
asList
(
null
,
getValue
(
"10"
),
null
,
getValue
(
"5"
)
)
);
}
@Override
protected
List
<
List
<
Long
>>
getInputOrderSets
()
{
return
Arrays
.
asList
(
Arrays
.
asList
(
10L
,
2L
,
5L
,
6L
,
11L
,
3L
,
7L
,
5L
),
Arrays
.
asList
(
8L
,
6L
,
9L
,
5L
),
Arrays
.
asList
(
null
,
6L
,
4L
,
3L
)
);
}
@Override
protected
List
<
T
>
getExpectedResults
()
{
return
Arrays
.
asList
(
getValue
(
"3"
),
null
,
getValue
(
"5"
)
);
}
}
}
flink-table/flink-table-planner-blink/src/test/java/org/apache/flink/table/planner/functions/aggfunctions/FirstValueWithRetractAggFunctionWithoutOrderTest.java
浏览文件 @
b3c86a81
...
...
@@ -45,71 +45,19 @@ import java.util.List;
* This class tests `accumulate` method without order argument.
*/
@RunWith
(
Enclosed
.
class
)
public
class
FirstValueWithRetractAggFunctionWithoutOrderTest
{
public
final
class
FirstValueWithRetractAggFunctionWithoutOrderTest
{
/**
* The base test class for FirstValueWithRetractAggFunction without order.
*/
public
abstract
static
class
FirstValueWithRetractAggFunctionWithoutOrderTestBase
<
T
>
extends
AggFunctionTestBase
<
T
,
GenericRow
>
{
@Override
protected
Class
<?>
getAccClass
()
{
return
GenericRow
.
class
;
}
@Override
protected
Method
getRetractFunc
()
throws
NoSuchMethodException
{
return
getAggregator
().
getClass
().
getMethod
(
"retract"
,
getAccClass
(),
Object
.
class
);
}
}
/**
* Test FirstValueWithRetractAggFunction for number type.
*/
public
abstract
static
class
NumberFirstValueWithRetractAggFunctionWithoutOrderTestBase
<
T
>
extends
FirstValueWithRetractAggFunctionWithoutOrderTestBase
<
T
>
{
protected
abstract
T
getValue
(
String
v
);
@Override
protected
List
<
List
<
T
>>
getInputValueSets
()
{
return
Arrays
.
asList
(
Arrays
.
asList
(
getValue
(
"1"
),
null
,
getValue
(
"-99"
),
getValue
(
"3"
),
null
),
Arrays
.
asList
(
null
,
null
,
null
,
null
),
Arrays
.
asList
(
null
,
getValue
(
"10"
),
null
,
getValue
(
"3"
)
)
);
}
@Override
protected
List
<
T
>
getExpectedResults
()
{
return
Arrays
.
asList
(
getValue
(
"1"
),
null
,
getValue
(
"10"
)
);
}
}
// --------------------------------------------------------------------------------------------
// Test sets for a particular type being aggregated
//
// Actual tests are implemented in:
// - AggFunctionTestBase
// --------------------------------------------------------------------------------------------
/**
* Test for ByteFirstValueWithRetractAggFunction.
*/
public
static
class
ByteFirstValueWithRetractAggFunctionWithoutOrderTest
public
static
final
class
ByteFirstValueWithRetractAggFunctionWithoutOrderTest
extends
NumberFirstValueWithRetractAggFunctionWithoutOrderTestBase
<
Byte
>
{
@Override
...
...
@@ -126,7 +74,7 @@ public class FirstValueWithRetractAggFunctionWithoutOrderTest {
/**
* Test for ShortFirstValueWithRetractAggFunction.
*/
public
static
class
ShortFirstValueWithRetractAggFunctionWithoutOrderTest
public
static
final
class
ShortFirstValueWithRetractAggFunctionWithoutOrderTest
extends
NumberFirstValueWithRetractAggFunctionWithoutOrderTestBase
<
Short
>
{
@Override
...
...
@@ -143,7 +91,7 @@ public class FirstValueWithRetractAggFunctionWithoutOrderTest {
/**
* Test for IntFirstValueWithRetractAggFunction.
*/
public
static
class
IntFirstValueWithRetractAggFunctionWithoutOrderTest
public
static
final
class
IntFirstValueWithRetractAggFunctionWithoutOrderTest
extends
NumberFirstValueWithRetractAggFunctionWithoutOrderTestBase
<
Integer
>
{
@Override
...
...
@@ -160,7 +108,7 @@ public class FirstValueWithRetractAggFunctionWithoutOrderTest {
/**
* Test for LongFirstValueWithRetractAggFunction.
*/
public
static
class
LongFirstValueWithRetractAggFunctionWithoutOrderTest
public
static
final
class
LongFirstValueWithRetractAggFunctionWithoutOrderTest
extends
NumberFirstValueWithRetractAggFunctionWithoutOrderTestBase
<
Long
>
{
@Override
...
...
@@ -177,7 +125,7 @@ public class FirstValueWithRetractAggFunctionWithoutOrderTest {
/**
* Test for FloatFirstValueWithRetractAggFunction.
*/
public
static
class
FloatFirstValueWithRetractAggFunctionWithoutOrderTest
public
static
final
class
FloatFirstValueWithRetractAggFunctionWithoutOrderTest
extends
NumberFirstValueWithRetractAggFunctionWithoutOrderTestBase
<
Float
>
{
@Override
...
...
@@ -194,7 +142,7 @@ public class FirstValueWithRetractAggFunctionWithoutOrderTest {
/**
* Test for DoubleFirstValueWithRetractAggFunction.
*/
public
static
class
DoubleFirstValueWithRetractAggFunctionWithoutOrderTest
public
static
final
class
DoubleFirstValueWithRetractAggFunctionWithoutOrderTest
extends
NumberFirstValueWithRetractAggFunctionWithoutOrderTestBase
<
Double
>
{
@Override
...
...
@@ -211,7 +159,7 @@ public class FirstValueWithRetractAggFunctionWithoutOrderTest {
/**
* Test for BooleanFirstValueWithRetractAggFunction.
*/
public
static
class
BooleanFirstValueWithRetractAggFunctionWithoutOrderTest
extends
public
static
final
class
BooleanFirstValueWithRetractAggFunctionWithoutOrderTest
extends
FirstValueWithRetractAggFunctionWithoutOrderTestBase
<
Boolean
>
{
@Override
...
...
@@ -267,7 +215,7 @@ public class FirstValueWithRetractAggFunctionWithoutOrderTest {
/**
* Test for DecimalFirstValueWithRetractAggFunction.
*/
public
static
class
DecimalFirstValueWithRetractAggFunctionWithoutOrderTest
extends
public
static
final
class
DecimalFirstValueWithRetractAggFunctionWithoutOrderTest
extends
FirstValueWithRetractAggFunctionWithoutOrderTestBase
<
Decimal
>
{
private
int
precision
=
20
;
...
...
@@ -319,7 +267,7 @@ public class FirstValueWithRetractAggFunctionWithoutOrderTest {
/**
* Test for StringFirstValueWithRetractAggFunction.
*/
public
static
class
StringFirstValueWithRetractAggFunctionWithoutOrderTest
extends
public
static
final
class
StringFirstValueWithRetractAggFunctionWithoutOrderTest
extends
FirstValueWithRetractAggFunctionWithoutOrderTestBase
<
BinaryString
>
{
@Override
...
...
@@ -365,4 +313,71 @@ public class FirstValueWithRetractAggFunctionWithoutOrderTest {
return
new
StringFirstValueWithRetractAggFunction
();
}
}
// --------------------------------------------------------------------------------------------
// This section contain base classes that provide common:
// - inputs
// - accumulator class
// - accessor for retract function
// for tests declared above.
// --------------------------------------------------------------------------------------------
/**
* The base test class for FirstValueWithRetractAggFunction without order.
*/
public
abstract
static
class
FirstValueWithRetractAggFunctionWithoutOrderTestBase
<
T
>
extends
AggFunctionTestBase
<
T
,
GenericRow
>
{
@Override
protected
Class
<?>
getAccClass
()
{
return
GenericRow
.
class
;
}
@Override
protected
Method
getRetractFunc
()
throws
NoSuchMethodException
{
return
getAggregator
().
getClass
().
getMethod
(
"retract"
,
getAccClass
(),
Object
.
class
);
}
}
/**
* Test FirstValueWithRetractAggFunction for number type.
*/
public
abstract
static
class
NumberFirstValueWithRetractAggFunctionWithoutOrderTestBase
<
T
>
extends
FirstValueWithRetractAggFunctionWithoutOrderTestBase
<
T
>
{
protected
abstract
T
getValue
(
String
v
);
@Override
protected
List
<
List
<
T
>>
getInputValueSets
()
{
return
Arrays
.
asList
(
Arrays
.
asList
(
getValue
(
"1"
),
null
,
getValue
(
"-99"
),
getValue
(
"3"
),
null
),
Arrays
.
asList
(
null
,
null
,
null
,
null
),
Arrays
.
asList
(
null
,
getValue
(
"10"
),
null
,
getValue
(
"3"
)
)
);
}
@Override
protected
List
<
T
>
getExpectedResults
()
{
return
Arrays
.
asList
(
getValue
(
"1"
),
null
,
getValue
(
"10"
)
);
}
}
}
flink-table/flink-table-planner-blink/src/test/java/org/apache/flink/table/planner/functions/aggfunctions/LastValueAggFunctionWithOrderTest.java
浏览文件 @
b3c86a81
...
...
@@ -44,93 +44,20 @@ import java.util.List;
* This class tests `accumulate` method with order argument.
*/
@RunWith
(
Enclosed
.
class
)
public
class
LastValueAggFunctionWithOrderTest
{
public
final
class
LastValueAggFunctionWithOrderTest
{
/**
* The base test class for LastValueAggFunction with order.
*/
public
abstract
static
class
LastValueAggFunctionWithOrderTestBase
<
T
>
extends
FirstLastValueAggFunctionWithOrderTestBase
<
T
>
{
}
/**
* Test LastValueAggFunction for number type.
*/
public
abstract
static
class
NumberLastValueAggFunctionWithOrderTestBase
<
T
>
extends
LastValueAggFunctionWithOrderTestBase
<
T
>
{
protected
abstract
T
getValue
(
String
v
);
@Override
protected
List
<
List
<
T
>>
getInputValueSets
()
{
return
Arrays
.
asList
(
Arrays
.
asList
(
getValue
(
"1"
),
null
,
getValue
(
"-99"
),
getValue
(
"3"
),
null
,
getValue
(
"3"
),
getValue
(
"2"
),
getValue
(
"-99"
)
),
Arrays
.
asList
(
null
,
null
,
null
,
null
),
Arrays
.
asList
(
null
,
getValue
(
"10"
),
null
,
getValue
(
"5"
)
)
);
}
@Override
protected
List
<
List
<
Long
>>
getInputOrderSets
()
{
return
Arrays
.
asList
(
Arrays
.
asList
(
10L
,
2L
,
5L
,
6L
,
11L
,
3L
,
17L
,
5L
),
Arrays
.
asList
(
8L
,
6L
,
9L
,
5L
),
Arrays
.
asList
(
null
,
6L
,
4L
,
3L
)
);
}
@Override
protected
List
<
T
>
getExpectedResults
()
{
return
Arrays
.
asList
(
getValue
(
"2"
),
null
,
getValue
(
"10"
)
);
}
}
// --------------------------------------------------------------------------------------------
// Test sets for a particular type being aggregated
//
// Actual tests are implemented in:
// - FirstLastValueAggFunctionWithOrderTestBase -> tests specific for FirstValue and LastValue
// - AggFunctionTestBase -> tests that apply to all aggregate functions
// --------------------------------------------------------------------------------------------
/**
* Test for ByteLastValueAggFunction.
*/
public
static
class
ByteLastValueAggFunctionWithOrderTest
public
static
final
class
ByteLastValueAggFunctionWithOrderTest
extends
NumberLastValueAggFunctionWithOrderTestBase
<
Byte
>
{
@Override
...
...
@@ -147,7 +74,7 @@ public class LastValueAggFunctionWithOrderTest {
/**
* Test for ShortLastValueAggFunction.
*/
public
static
class
ShortLastValueAggFunctionWithOrderTest
public
static
final
class
ShortLastValueAggFunctionWithOrderTest
extends
NumberLastValueAggFunctionWithOrderTestBase
<
Short
>
{
@Override
...
...
@@ -164,7 +91,7 @@ public class LastValueAggFunctionWithOrderTest {
/**
* Test for IntLastValueAggFunction.
*/
public
static
class
IntLastValueAggFunctionWithOrderTest
public
static
final
class
IntLastValueAggFunctionWithOrderTest
extends
NumberLastValueAggFunctionWithOrderTestBase
<
Integer
>
{
@Override
...
...
@@ -181,7 +108,7 @@ public class LastValueAggFunctionWithOrderTest {
/**
* Test for LongLastValueAggFunction.
*/
public
static
class
LongLastValueAggFunctionWithOrderTest
public
static
final
class
LongLastValueAggFunctionWithOrderTest
extends
NumberLastValueAggFunctionWithOrderTestBase
<
Long
>
{
@Override
...
...
@@ -198,7 +125,7 @@ public class LastValueAggFunctionWithOrderTest {
/**
* Test for FloatLastValueAggFunction.
*/
public
static
class
FloatLastValueAggFunctionWithOrderTest
public
static
final
class
FloatLastValueAggFunctionWithOrderTest
extends
NumberLastValueAggFunctionWithOrderTestBase
<
Float
>
{
@Override
...
...
@@ -215,7 +142,7 @@ public class LastValueAggFunctionWithOrderTest {
/**
* Test for DoubleLastValueAggFunction.
*/
public
static
class
DoubleLastValueAggFunctionWithOrderTest
public
static
final
class
DoubleLastValueAggFunctionWithOrderTest
extends
NumberLastValueAggFunctionWithOrderTestBase
<
Double
>
{
@Override
...
...
@@ -232,8 +159,8 @@ public class LastValueAggFunctionWithOrderTest {
/**
* Test for BooleanLastValueAggFunction.
*/
public
static
class
BooleanLastValueAggFunctionWithOrderTest
extends
LastValueAggFunctionWithOrderTestBase
<
Boolean
>
{
public
static
final
class
BooleanLastValueAggFunctionWithOrderTest
extends
First
LastValueAggFunctionWithOrderTestBase
<
Boolean
>
{
@Override
protected
List
<
List
<
Boolean
>>
getInputValueSets
()
{
...
...
@@ -322,8 +249,8 @@ public class LastValueAggFunctionWithOrderTest {
/**
* Test for DecimalLastValueAggFunction.
*/
public
static
class
DecimalLastValueAggFunctionWithOrderTest
extends
LastValueAggFunctionWithOrderTestBase
<
Decimal
>
{
public
static
final
class
DecimalLastValueAggFunctionWithOrderTest
extends
First
LastValueAggFunctionWithOrderTestBase
<
Decimal
>
{
private
int
precision
=
20
;
private
int
scale
=
6
;
...
...
@@ -402,8 +329,8 @@ public class LastValueAggFunctionWithOrderTest {
/**
* Test for StringLastValueAggFunction.
*/
public
static
class
StringLastValueAggFunctionWithOrderTest
extends
LastValueAggFunctionWithOrderTestBase
<
BinaryString
>
{
public
static
final
class
StringLastValueAggFunctionWithOrderTest
extends
First
LastValueAggFunctionWithOrderTestBase
<
BinaryString
>
{
@Override
protected
List
<
List
<
BinaryString
>>
getInputValueSets
()
{
...
...
@@ -476,4 +403,81 @@ public class LastValueAggFunctionWithOrderTest {
return
new
StringLastValueAggFunction
();
}
}
// --------------------------------------------------------------------------------------------
// This section contain base classes that provide common inputs for tests declared above.
// --------------------------------------------------------------------------------------------
/**
* Test LastValueAggFunction for number type.
*/
public
abstract
static
class
NumberLastValueAggFunctionWithOrderTestBase
<
T
>
extends
FirstLastValueAggFunctionWithOrderTestBase
<
T
>
{
protected
abstract
T
getValue
(
String
v
);
@Override
protected
List
<
List
<
T
>>
getInputValueSets
()
{
return
Arrays
.
asList
(
Arrays
.
asList
(
getValue
(
"1"
),
null
,
getValue
(
"-99"
),
getValue
(
"3"
),
null
,
getValue
(
"3"
),
getValue
(
"2"
),
getValue
(
"-99"
)
),
Arrays
.
asList
(
null
,
null
,
null
,
null
),
Arrays
.
asList
(
null
,
getValue
(
"10"
),
null
,
getValue
(
"5"
)
)
);
}
@Override
protected
List
<
List
<
Long
>>
getInputOrderSets
()
{
return
Arrays
.
asList
(
Arrays
.
asList
(
10L
,
2L
,
5L
,
6L
,
11L
,
3L
,
17L
,
5L
),
Arrays
.
asList
(
8L
,
6L
,
9L
,
5L
),
Arrays
.
asList
(
null
,
6L
,
4L
,
3L
)
);
}
@Override
protected
List
<
T
>
getExpectedResults
()
{
return
Arrays
.
asList
(
getValue
(
"2"
),
null
,
getValue
(
"10"
)
);
}
}
}
flink-table/flink-table-planner-blink/src/test/java/org/apache/flink/table/planner/functions/aggfunctions/LastValueAggFunctionWithoutOrderTest.java
浏览文件 @
b3c86a81
...
...
@@ -44,66 +44,19 @@ import java.util.List;
* This class tests `accumulate` method without order argument.
*/
@RunWith
(
Enclosed
.
class
)
public
class
LastValueAggFunctionWithoutOrderTest
{
public
final
class
LastValueAggFunctionWithoutOrderTest
{
/**
* The base test class for LastValueAggFunction without order.
*/
public
abstract
static
class
LastValueAggFunctionWithoutOrderTestBase
<
T
>
extends
AggFunctionTestBase
<
T
,
GenericRow
>
{
@Override
protected
Class
<?>
getAccClass
()
{
return
GenericRow
.
class
;
}
}
/**
* Test LastValueAggFunction for number type.
*/
public
abstract
static
class
NumberLastValueAggFunctionWithoutOrderTestBase
<
T
>
extends
LastValueAggFunctionWithoutOrderTestBase
<
T
>
{
protected
abstract
T
getValue
(
String
v
);
@Override
protected
List
<
List
<
T
>>
getInputValueSets
()
{
return
Arrays
.
asList
(
Arrays
.
asList
(
getValue
(
"1"
),
null
,
getValue
(
"-99"
),
getValue
(
"3"
),
null
),
Arrays
.
asList
(
null
,
null
,
null
,
null
),
Arrays
.
asList
(
null
,
getValue
(
"10"
),
null
,
getValue
(
"3"
)
)
);
}
@Override
protected
List
<
T
>
getExpectedResults
()
{
return
Arrays
.
asList
(
getValue
(
"3"
),
null
,
getValue
(
"3"
)
);
}
}
// --------------------------------------------------------------------------------------------
// Test sets for a particular type being aggregated
//
// Actual tests are implemented in:
// - AggFunctionTestBase
// --------------------------------------------------------------------------------------------
/**
* Test for ByteLastValueAggFunction.
*/
public
static
class
ByteLastValueAggFunctionWithoutOrderTest
public
static
final
class
ByteLastValueAggFunctionWithoutOrderTest
extends
NumberLastValueAggFunctionWithoutOrderTestBase
<
Byte
>
{
@Override
...
...
@@ -120,7 +73,7 @@ public class LastValueAggFunctionWithoutOrderTest {
/**
* Test for ShortLastValueAggFunction.
*/
public
static
class
ShortLastValueAggFunctionWithoutOrderTest
public
static
final
class
ShortLastValueAggFunctionWithoutOrderTest
extends
NumberLastValueAggFunctionWithoutOrderTestBase
<
Short
>
{
@Override
...
...
@@ -137,7 +90,7 @@ public class LastValueAggFunctionWithoutOrderTest {
/**
* Test for IntLastValueAggFunction.
*/
public
static
class
IntLastValueAggFunctionWithoutOrderTest
public
static
final
class
IntLastValueAggFunctionWithoutOrderTest
extends
NumberLastValueAggFunctionWithoutOrderTestBase
<
Integer
>
{
@Override
...
...
@@ -154,7 +107,7 @@ public class LastValueAggFunctionWithoutOrderTest {
/**
* Test for LongLastValueAggFunction.
*/
public
static
class
LongLastValueAggFunctionWithoutOrderTest
public
static
final
class
LongLastValueAggFunctionWithoutOrderTest
extends
NumberLastValueAggFunctionWithoutOrderTestBase
<
Long
>
{
@Override
...
...
@@ -171,7 +124,7 @@ public class LastValueAggFunctionWithoutOrderTest {
/**
* Test for FloatLastValueAggFunction.
*/
public
static
class
FloatLastValueAggFunctionWithoutOrderTest
public
static
final
class
FloatLastValueAggFunctionWithoutOrderTest
extends
NumberLastValueAggFunctionWithoutOrderTestBase
<
Float
>
{
@Override
...
...
@@ -188,7 +141,7 @@ public class LastValueAggFunctionWithoutOrderTest {
/**
* Test for DoubleLastValueAggFunction.
*/
public
static
class
DoubleLastValueAggFunctionWithoutOrderTest
public
static
final
class
DoubleLastValueAggFunctionWithoutOrderTest
extends
NumberLastValueAggFunctionWithoutOrderTestBase
<
Double
>
{
@Override
...
...
@@ -205,7 +158,7 @@ public class LastValueAggFunctionWithoutOrderTest {
/**
* Test for BooleanLastValueAggFunction.
*/
public
static
class
BooleanLastValueAggFunctionWithoutOrderTest
extends
public
static
final
class
BooleanLastValueAggFunctionWithoutOrderTest
extends
LastValueAggFunctionWithoutOrderTestBase
<
Boolean
>
{
@Override
...
...
@@ -261,7 +214,7 @@ public class LastValueAggFunctionWithoutOrderTest {
/**
* Test for DecimalLastValueAggFunction.
*/
public
static
class
DecimalLastValueAggFunctionWithoutOrderTest
extends
public
static
final
class
DecimalLastValueAggFunctionWithoutOrderTest
extends
LastValueAggFunctionWithoutOrderTestBase
<
Decimal
>
{
private
int
precision
=
20
;
...
...
@@ -313,7 +266,7 @@ public class LastValueAggFunctionWithoutOrderTest {
/**
* Test for StringLastValueAggFunction.
*/
public
static
class
StringLastValueAggFunctionWithoutOrderTest
extends
public
static
final
class
StringLastValueAggFunctionWithoutOrderTest
extends
LastValueAggFunctionWithoutOrderTestBase
<
BinaryString
>
{
@Override
...
...
@@ -360,4 +313,63 @@ public class LastValueAggFunctionWithoutOrderTest {
return
new
StringLastValueAggFunction
();
}
}
// --------------------------------------------------------------------------------------------
// This section contain base classes that provide common inputs and declare the accumulator
// class type for tests declared above.
// --------------------------------------------------------------------------------------------
/**
* The base test class for LastValueAggFunction without order.
*/
public
abstract
static
class
LastValueAggFunctionWithoutOrderTestBase
<
T
>
extends
AggFunctionTestBase
<
T
,
GenericRow
>
{
@Override
protected
Class
<?>
getAccClass
()
{
return
GenericRow
.
class
;
}
}
/**
* Test LastValueAggFunction for number type.
*/
public
abstract
static
class
NumberLastValueAggFunctionWithoutOrderTestBase
<
T
>
extends
LastValueAggFunctionWithoutOrderTestBase
<
T
>
{
protected
abstract
T
getValue
(
String
v
);
@Override
protected
List
<
List
<
T
>>
getInputValueSets
()
{
return
Arrays
.
asList
(
Arrays
.
asList
(
getValue
(
"1"
),
null
,
getValue
(
"-99"
),
getValue
(
"3"
),
null
),
Arrays
.
asList
(
null
,
null
,
null
,
null
),
Arrays
.
asList
(
null
,
getValue
(
"10"
),
null
,
getValue
(
"3"
)
)
);
}
@Override
protected
List
<
T
>
getExpectedResults
()
{
return
Arrays
.
asList
(
getValue
(
"3"
),
null
,
getValue
(
"3"
)
);
}
}
}
flink-table/flink-table-planner-blink/src/test/java/org/apache/flink/table/planner/functions/aggfunctions/LastValueWithRetractAggFunctionWithOrderTest.java
浏览文件 @
b3c86a81
...
...
@@ -45,97 +45,20 @@ import java.util.List;
* This class tests `accumulate` method with order argument.
*/
@RunWith
(
Enclosed
.
class
)
public
class
LastValueWithRetractAggFunctionWithOrderTest
{
public
final
class
LastValueWithRetractAggFunctionWithOrderTest
{
/**
* The base test class for LastValueWithRetractAggFunction with order.
*/
public
abstract
static
class
LastValueWithRetractAggFunctionWithOrderTestBase
<
T
>
extends
FirstLastValueAggFunctionWithOrderTestBase
<
T
>
{
@Override
protected
Method
getRetractFunc
()
throws
NoSuchMethodException
{
return
getAggregator
().
getClass
().
getMethod
(
"retract"
,
getAccClass
(),
Object
.
class
,
Long
.
class
);
}
}
/**
* Test LastValueWithRetractAggFunction for number type.
*/
public
abstract
static
class
NumberLastValueWithRetractAggFunctionWithOrderTestBase
<
T
>
extends
LastValueWithRetractAggFunctionWithOrderTestBase
<
T
>
{
protected
abstract
T
getValue
(
String
v
);
@Override
protected
List
<
List
<
T
>>
getInputValueSets
()
{
return
Arrays
.
asList
(
Arrays
.
asList
(
getValue
(
"1"
),
null
,
getValue
(
"-99"
),
getValue
(
"3"
),
null
,
getValue
(
"3"
),
getValue
(
"2"
),
getValue
(
"-99"
)
),
Arrays
.
asList
(
null
,
null
,
null
,
null
),
Arrays
.
asList
(
null
,
getValue
(
"10"
),
null
,
getValue
(
"5"
)
)
);
}
@Override
protected
List
<
List
<
Long
>>
getInputOrderSets
()
{
return
Arrays
.
asList
(
Arrays
.
asList
(
10L
,
2L
,
5L
,
6L
,
11L
,
13L
,
7L
,
5L
),
Arrays
.
asList
(
8L
,
6L
,
9L
,
5L
),
Arrays
.
asList
(
null
,
6L
,
4L
,
3L
)
);
}
@Override
protected
List
<
T
>
getExpectedResults
()
{
return
Arrays
.
asList
(
getValue
(
"3"
),
null
,
getValue
(
"10"
)
);
}
}
// --------------------------------------------------------------------------------------------
// Test sets for a particular type being aggregated
//
// Actual tests are implemented in:
// - FirstLastValueAggFunctionWithOrderTestBase -> tests specific for FirstValue and LastValue
// - AggFunctionTestBase -> tests that apply to all aggregate functions
// --------------------------------------------------------------------------------------------
/**
* Test for ByteLastValueWithRetractAggFunction.
*/
public
static
class
ByteLastValueWithRetractAggFunctionWithOrderTest
public
static
final
class
ByteLastValueWithRetractAggFunctionWithOrderTest
extends
NumberLastValueWithRetractAggFunctionWithOrderTestBase
<
Byte
>
{
@Override
...
...
@@ -152,7 +75,7 @@ public class LastValueWithRetractAggFunctionWithOrderTest {
/**
* Test for ShortLastValueWithRetractAggFunction.
*/
public
static
class
ShortLastValueWithRetractAggFunctionWithOrderTest
public
static
final
class
ShortLastValueWithRetractAggFunctionWithOrderTest
extends
NumberLastValueWithRetractAggFunctionWithOrderTestBase
<
Short
>
{
@Override
...
...
@@ -169,7 +92,7 @@ public class LastValueWithRetractAggFunctionWithOrderTest {
/**
* Test for IntLastValueWithRetractAggFunction.
*/
public
static
class
IntLastValueWithRetractAggFunctionWithOrderTest
public
static
final
class
IntLastValueWithRetractAggFunctionWithOrderTest
extends
NumberLastValueWithRetractAggFunctionWithOrderTestBase
<
Integer
>
{
@Override
...
...
@@ -186,7 +109,7 @@ public class LastValueWithRetractAggFunctionWithOrderTest {
/**
* Test for LongLastValueWithRetractAggFunction.
*/
public
static
class
LongLastValueWithRetractAggFunctionWithOrderTest
public
static
final
class
LongLastValueWithRetractAggFunctionWithOrderTest
extends
NumberLastValueWithRetractAggFunctionWithOrderTestBase
<
Long
>
{
@Override
...
...
@@ -203,7 +126,7 @@ public class LastValueWithRetractAggFunctionWithOrderTest {
/**
* Test for FloatLastValueWithRetractAggFunction.
*/
public
static
class
FloatLastValueWithRetractAggFunctionWithOrderTest
public
static
final
class
FloatLastValueWithRetractAggFunctionWithOrderTest
extends
NumberLastValueWithRetractAggFunctionWithOrderTestBase
<
Float
>
{
@Override
...
...
@@ -220,7 +143,7 @@ public class LastValueWithRetractAggFunctionWithOrderTest {
/**
* Test for DoubleLastValueWithRetractAggFunction.
*/
public
static
class
DoubleLastValueWithRetractAggFunctionWithOrderTest
public
static
final
class
DoubleLastValueWithRetractAggFunctionWithOrderTest
extends
NumberLastValueWithRetractAggFunctionWithOrderTestBase
<
Double
>
{
@Override
...
...
@@ -237,7 +160,7 @@ public class LastValueWithRetractAggFunctionWithOrderTest {
/**
* Test for BooleanLastValueWithRetractAggFunction.
*/
public
static
class
BooleanLastValueWithRetractAggFunctionWithOrderTest
public
static
final
class
BooleanLastValueWithRetractAggFunctionWithOrderTest
extends
LastValueWithRetractAggFunctionWithOrderTestBase
<
Boolean
>
{
@Override
...
...
@@ -324,10 +247,11 @@ public class LastValueWithRetractAggFunctionWithOrderTest {
}
}
/**
* Test for DecimalLastValueWithRetractAggFunction.
*/
public
static
class
DecimalLastValueWithRetractAggFunctionWithOrderTest
public
static
final
class
DecimalLastValueWithRetractAggFunctionWithOrderTest
extends
LastValueWithRetractAggFunctionWithOrderTestBase
<
Decimal
>
{
private
int
precision
=
20
;
...
...
@@ -407,7 +331,7 @@ public class LastValueWithRetractAggFunctionWithOrderTest {
/**
* Test for StringLastValueWithRetractAggFunction.
*/
public
static
class
StringLastValueWithRetractAggFunctionWithOrderTest
public
static
final
class
StringLastValueWithRetractAggFunctionWithOrderTest
extends
LastValueWithRetractAggFunctionWithOrderTestBase
<
BinaryString
>
{
@Override
...
...
@@ -487,4 +411,94 @@ public class LastValueWithRetractAggFunctionWithOrderTest {
return
new
StringLastValueWithRetractAggFunction
();
}
}
// --------------------------------------------------------------------------------------------
// This section contain base classes that provide common inputs and accessor for retract function
// for tests declared above.
// --------------------------------------------------------------------------------------------
/**
* The base test class for LastValueWithRetractAggFunction with order.
*/
public
abstract
static
class
LastValueWithRetractAggFunctionWithOrderTestBase
<
T
>
extends
FirstLastValueAggFunctionWithOrderTestBase
<
T
>
{
@Override
protected
Method
getRetractFunc
()
throws
NoSuchMethodException
{
return
getAggregator
().
getClass
().
getMethod
(
"retract"
,
getAccClass
(),
Object
.
class
,
Long
.
class
);
}
}
/**
* Test LastValueWithRetractAggFunction for number type.
*/
public
abstract
static
class
NumberLastValueWithRetractAggFunctionWithOrderTestBase
<
T
>
extends
LastValueWithRetractAggFunctionWithOrderTestBase
<
T
>
{
protected
abstract
T
getValue
(
String
v
);
@Override
protected
List
<
List
<
T
>>
getInputValueSets
()
{
return
Arrays
.
asList
(
Arrays
.
asList
(
getValue
(
"1"
),
null
,
getValue
(
"-99"
),
getValue
(
"3"
),
null
,
getValue
(
"3"
),
getValue
(
"2"
),
getValue
(
"-99"
)
),
Arrays
.
asList
(
null
,
null
,
null
,
null
),
Arrays
.
asList
(
null
,
getValue
(
"10"
),
null
,
getValue
(
"5"
)
)
);
}
@Override
protected
List
<
List
<
Long
>>
getInputOrderSets
()
{
return
Arrays
.
asList
(
Arrays
.
asList
(
10L
,
2L
,
5L
,
6L
,
11L
,
13L
,
7L
,
5L
),
Arrays
.
asList
(
8L
,
6L
,
9L
,
5L
),
Arrays
.
asList
(
null
,
6L
,
4L
,
3L
)
);
}
@Override
protected
List
<
T
>
getExpectedResults
()
{
return
Arrays
.
asList
(
getValue
(
"3"
),
null
,
getValue
(
"10"
)
);
}
}
}
flink-table/flink-table-planner-blink/src/test/java/org/apache/flink/table/planner/functions/aggfunctions/LastValueWithRetractAggFunctionWithoutOrderTest.java
浏览文件 @
b3c86a81
...
...
@@ -45,71 +45,19 @@ import java.util.List;
* This class tests `accumulate` method without order argument.
*/
@RunWith
(
Enclosed
.
class
)
public
class
LastValueWithRetractAggFunctionWithoutOrderTest
{
public
final
class
LastValueWithRetractAggFunctionWithoutOrderTest
{
/**
* The base test class for LastValueWithRetractAggFunction without order.
*/
public
abstract
static
class
LastValueWithRetractAggFunctionWithoutOrderTestBase
<
T
>
extends
AggFunctionTestBase
<
T
,
GenericRow
>
{
@Override
protected
Class
<?>
getAccClass
()
{
return
GenericRow
.
class
;
}
@Override
protected
Method
getRetractFunc
()
throws
NoSuchMethodException
{
return
getAggregator
().
getClass
().
getMethod
(
"retract"
,
getAccClass
(),
Object
.
class
);
}
}
/**
* Test LastValueWithRetractAggFunction for number type.
*/
public
abstract
static
class
NumberLastValueWithRetractAggFunctionWithoutOrderTestBase
<
T
>
extends
LastValueWithRetractAggFunctionWithoutOrderTestBase
<
T
>
{
protected
abstract
T
getValue
(
String
v
);
@Override
protected
List
<
List
<
T
>>
getInputValueSets
()
{
return
Arrays
.
asList
(
Arrays
.
asList
(
getValue
(
"1"
),
null
,
getValue
(
"-99"
),
getValue
(
"3"
),
null
),
Arrays
.
asList
(
null
,
null
,
null
,
null
),
Arrays
.
asList
(
null
,
getValue
(
"10"
),
null
,
getValue
(
"3"
)
)
);
}
@Override
protected
List
<
T
>
getExpectedResults
()
{
return
Arrays
.
asList
(
getValue
(
"3"
),
null
,
getValue
(
"3"
)
);
}
}
// --------------------------------------------------------------------------------------------
// Test sets for a particular type being aggregated
//
// Actual tests are implemented in:
// - AggFunctionTestBase
// --------------------------------------------------------------------------------------------
/**
* Test for ByteLastValueWithRetractAggFunction.
*/
public
static
class
ByteLastValueWithRetractAggFunctionWithoutOrderTest
public
static
final
class
ByteLastValueWithRetractAggFunctionWithoutOrderTest
extends
NumberLastValueWithRetractAggFunctionWithoutOrderTestBase
<
Byte
>
{
@Override
...
...
@@ -126,7 +74,7 @@ public class LastValueWithRetractAggFunctionWithoutOrderTest {
/**
* Test for ShortLastValueWithRetractAggFunction.
*/
public
static
class
ShortLastValueWithRetractAggFunctionWithoutOrderTest
public
static
final
class
ShortLastValueWithRetractAggFunctionWithoutOrderTest
extends
NumberLastValueWithRetractAggFunctionWithoutOrderTestBase
<
Short
>
{
@Override
...
...
@@ -143,7 +91,7 @@ public class LastValueWithRetractAggFunctionWithoutOrderTest {
/**
* Test for IntLastValueWithRetractAggFunction.
*/
public
static
class
IntLastValueWithRetractAggFunctionWithoutOrderTest
public
static
final
class
IntLastValueWithRetractAggFunctionWithoutOrderTest
extends
NumberLastValueWithRetractAggFunctionWithoutOrderTestBase
<
Integer
>
{
@Override
...
...
@@ -160,7 +108,7 @@ public class LastValueWithRetractAggFunctionWithoutOrderTest {
/**
* Test for LongLastValueWithRetractAggFunction.
*/
public
static
class
LongLastValueWithRetractAggFunctionWithoutOrderTest
public
static
final
class
LongLastValueWithRetractAggFunctionWithoutOrderTest
extends
NumberLastValueWithRetractAggFunctionWithoutOrderTestBase
<
Long
>
{
@Override
...
...
@@ -177,7 +125,7 @@ public class LastValueWithRetractAggFunctionWithoutOrderTest {
/**
* Test for FloatLastValueWithRetractAggFunction.
*/
public
static
class
FloatLastValueWithRetractAggFunctionWithoutOrderTest
public
static
final
class
FloatLastValueWithRetractAggFunctionWithoutOrderTest
extends
NumberLastValueWithRetractAggFunctionWithoutOrderTestBase
<
Float
>
{
@Override
...
...
@@ -194,7 +142,7 @@ public class LastValueWithRetractAggFunctionWithoutOrderTest {
/**
* Test for DoubleLastValueWithRetractAggFunction.
*/
public
static
class
DoubleLastValueWithRetractAggFunctionWithoutOrderTest
public
static
final
class
DoubleLastValueWithRetractAggFunctionWithoutOrderTest
extends
NumberLastValueWithRetractAggFunctionWithoutOrderTestBase
<
Double
>
{
@Override
...
...
@@ -211,7 +159,7 @@ public class LastValueWithRetractAggFunctionWithoutOrderTest {
/**
* Test for BooleanLastValueWithRetractAggFunction.
*/
public
static
class
BooleanLastValueWithRetractAggFunctionWithoutOrderTest
extends
public
static
final
class
BooleanLastValueWithRetractAggFunctionWithoutOrderTest
extends
LastValueWithRetractAggFunctionWithoutOrderTestBase
<
Boolean
>
{
@Override
...
...
@@ -267,7 +215,7 @@ public class LastValueWithRetractAggFunctionWithoutOrderTest {
/**
* Test for DecimalLastValueWithRetractAggFunction.
*/
public
static
class
DecimalLastValueWithRetractAggFunctionWithoutOrderTest
extends
public
static
final
class
DecimalLastValueWithRetractAggFunctionWithoutOrderTest
extends
LastValueWithRetractAggFunctionWithoutOrderTestBase
<
Decimal
>
{
private
int
precision
=
20
;
...
...
@@ -319,7 +267,7 @@ public class LastValueWithRetractAggFunctionWithoutOrderTest {
/**
* Test for StringLastValueWithRetractAggFunction.
*/
public
static
class
StringLastValueWithRetractAggFunctionWithoutOrderTest
extends
public
static
final
class
StringLastValueWithRetractAggFunctionWithoutOrderTest
extends
LastValueWithRetractAggFunctionWithoutOrderTestBase
<
BinaryString
>
{
@Override
...
...
@@ -365,4 +313,71 @@ public class LastValueWithRetractAggFunctionWithoutOrderTest {
return
new
StringLastValueWithRetractAggFunction
();
}
}
// --------------------------------------------------------------------------------------------
// This section contain base classes that provide:
// - common inputs
// - declare the accumulator class
// - accessor for retract function
// for tests declared above.
// --------------------------------------------------------------------------------------------
/**
* The base test class for LastValueWithRetractAggFunction without order.
*/
public
abstract
static
class
LastValueWithRetractAggFunctionWithoutOrderTestBase
<
T
>
extends
AggFunctionTestBase
<
T
,
GenericRow
>
{
@Override
protected
Class
<?>
getAccClass
()
{
return
GenericRow
.
class
;
}
@Override
protected
Method
getRetractFunc
()
throws
NoSuchMethodException
{
return
getAggregator
().
getClass
().
getMethod
(
"retract"
,
getAccClass
(),
Object
.
class
);
}
}
/**
* Test LastValueWithRetractAggFunction for number type.
*/
public
abstract
static
class
NumberLastValueWithRetractAggFunctionWithoutOrderTestBase
<
T
>
extends
LastValueWithRetractAggFunctionWithoutOrderTestBase
<
T
>
{
protected
abstract
T
getValue
(
String
v
);
@Override
protected
List
<
List
<
T
>>
getInputValueSets
()
{
return
Arrays
.
asList
(
Arrays
.
asList
(
getValue
(
"1"
),
null
,
getValue
(
"-99"
),
getValue
(
"3"
),
null
),
Arrays
.
asList
(
null
,
null
,
null
,
null
),
Arrays
.
asList
(
null
,
getValue
(
"10"
),
null
,
getValue
(
"3"
)
)
);
}
@Override
protected
List
<
T
>
getExpectedResults
()
{
return
Arrays
.
asList
(
getValue
(
"3"
),
null
,
getValue
(
"3"
)
);
}
}
}
flink-table/flink-table-planner-blink/src/test/java/org/apache/flink/table/planner/functions/aggfunctions/ListAggWithRetractAggFunctionTest.java
浏览文件 @
b3c86a81
...
...
@@ -29,7 +29,7 @@ import java.util.List;
/**
* Test case for built-in LISTAGG with retraction aggregate function.
*/
public
class
ListAggWithRetractAggFunctionTest
public
final
class
ListAggWithRetractAggFunctionTest
extends
AggFunctionTestBase
<
BinaryString
,
ListAggWithRetractAccumulator
>
{
@Override
...
...
flink-table/flink-table-planner-blink/src/test/java/org/apache/flink/table/planner/functions/aggfunctions/ListAggWsWithRetractAggFunctionTest.java
浏览文件 @
b3c86a81
...
...
@@ -35,7 +35,7 @@ import static org.junit.Assert.assertEquals;
/**
* Test case for built-in ListAggWs with retraction aggregate function.
*/
public
class
ListAggWsWithRetractAggFunctionTest
public
final
class
ListAggWsWithRetractAggFunctionTest
extends
AggFunctionTestBase
<
BinaryString
,
ListAggWsWithRetractAccumulator
>
{
@Override
...
...
flink-table/flink-table-planner-blink/src/test/java/org/apache/flink/table/planner/functions/aggfunctions/MaxWithRetractAggFunctionTest.java
浏览文件 @
b3c86a81
...
...
@@ -50,80 +50,19 @@ import java.util.List;
* Test case for built-in Max with retraction aggregate function.
*/
@RunWith
(
Enclosed
.
class
)
public
class
MaxWithRetractAggFunctionTest
{
public
final
class
MaxWithRetractAggFunctionTest
{
/**
* The base test class for MaxWithRetractAggFunction.
*/
public
abstract
static
class
MaxWithRetractAggFunctionTestBase
<
T
>
extends
AggFunctionTestBase
<
T
,
MaxWithRetractAccumulator
<
T
>>
{
@Override
protected
Class
<?>
getAccClass
()
{
return
MaxWithRetractAccumulator
.
class
;
}
@Override
protected
Method
getRetractFunc
()
throws
NoSuchMethodException
{
return
getAggregator
().
getClass
().
getMethod
(
"retract"
,
getAccClass
(),
Object
.
class
);
}
}
/**
* Test MaxWithRetractAggFunction for number type.
*/
public
abstract
static
class
NumberMaxWithRetractAggFunctionTest
<
T
>
extends
MaxWithRetractAggFunctionTestBase
{
protected
abstract
T
getMinValue
();
protected
abstract
T
getMaxValue
();
protected
abstract
T
getValue
(
String
v
);
@Override
protected
List
<
List
<
T
>>
getInputValueSets
()
{
return
Arrays
.
asList
(
Arrays
.
asList
(
getValue
(
"1"
),
null
,
getMaxValue
(),
getValue
(
"-99"
),
getValue
(
"3"
),
getValue
(
"56"
),
getValue
(
"0"
),
getMinValue
(),
getValue
(
"-20"
),
getValue
(
"17"
),
null
),
Arrays
.
asList
(
null
,
null
,
null
,
null
,
null
,
null
),
Arrays
.
asList
(
null
,
getValue
(
"10"
)
)
);
}
@Override
protected
List
<
T
>
getExpectedResults
()
{
return
Arrays
.
asList
(
getMaxValue
(),
null
,
getValue
(
"10"
)
);
}
}
// --------------------------------------------------------------------------------------------
// Test sets for a particular type being aggregated
//
// Actual tests are implemented in:
// - AggFunctionTestBase
// --------------------------------------------------------------------------------------------
/**
* Test for ByteMaxWithRetractAggFunction.
*/
public
static
class
ByteMaxWithRetractAggFunctionTest
extends
NumberMaxWithRetractAggFunctionTest
<
Byte
>
{
public
static
final
class
ByteMaxWithRetractAggFunctionTest
extends
NumberMaxWithRetractAggFunctionTest
<
Byte
>
{
@Override
protected
Byte
getMinValue
()
{
...
...
@@ -149,7 +88,7 @@ public class MaxWithRetractAggFunctionTest {
/**
* Test for ShortMaxWithRetractAggFunction.
*/
public
static
class
ShortMaxWithRetractAggFunctionTest
extends
NumberMaxWithRetractAggFunctionTest
<
Short
>
{
public
static
final
class
ShortMaxWithRetractAggFunctionTest
extends
NumberMaxWithRetractAggFunctionTest
<
Short
>
{
@Override
protected
Short
getMinValue
()
{
...
...
@@ -175,7 +114,7 @@ public class MaxWithRetractAggFunctionTest {
/**
* Test for IntMaxWithRetractAggFunction.
*/
public
static
class
IntMaxWithRetractAggFunctionTest
extends
NumberMaxWithRetractAggFunctionTest
<
Integer
>
{
public
static
final
class
IntMaxWithRetractAggFunctionTest
extends
NumberMaxWithRetractAggFunctionTest
<
Integer
>
{
@Override
protected
Integer
getMinValue
()
{
...
...
@@ -201,7 +140,7 @@ public class MaxWithRetractAggFunctionTest {
/**
* Test for LongMaxWithRetractAggFunction.
*/
public
static
class
LongMaxWithRetractAggFunctionTest
extends
NumberMaxWithRetractAggFunctionTest
<
Long
>
{
public
static
final
class
LongMaxWithRetractAggFunctionTest
extends
NumberMaxWithRetractAggFunctionTest
<
Long
>
{
@Override
protected
Long
getMinValue
()
{
...
...
@@ -227,7 +166,7 @@ public class MaxWithRetractAggFunctionTest {
/**
* Test for FloatMaxWithRetractAggFunction.
*/
public
static
class
FloatMaxWithRetractAggFunctionTest
extends
NumberMaxWithRetractAggFunctionTest
<
Float
>
{
public
static
final
class
FloatMaxWithRetractAggFunctionTest
extends
NumberMaxWithRetractAggFunctionTest
<
Float
>
{
@Override
protected
Float
getMinValue
()
{
...
...
@@ -253,7 +192,7 @@ public class MaxWithRetractAggFunctionTest {
/**
* Test for DoubleMaxWithRetractAggFunction.
*/
public
static
class
DoubleMaxWithRetractAggFunctionTest
extends
NumberMaxWithRetractAggFunctionTest
<
Double
>
{
public
static
final
class
DoubleMaxWithRetractAggFunctionTest
extends
NumberMaxWithRetractAggFunctionTest
<
Double
>
{
@Override
protected
Double
getMinValue
()
{
...
...
@@ -279,7 +218,7 @@ public class MaxWithRetractAggFunctionTest {
/**
* Test for BooleanMaxWithRetractAggFunction.
*/
public
static
class
BooleanMaxWithRetractAggFunctionTest
extends
MaxWithRetractAggFunctionTestBase
<
Boolean
>
{
public
static
final
class
BooleanMaxWithRetractAggFunctionTest
extends
MaxWithRetractAggFunctionTestBase
<
Boolean
>
{
@Override
protected
List
<
List
<
Boolean
>>
getInputValueSets
()
{
...
...
@@ -344,7 +283,7 @@ public class MaxWithRetractAggFunctionTest {
/**
* Test for DecimalMaxWithRetractAggFunction.
*/
public
static
class
DecimalMaxWithRetractAggFunctionTest
extends
MaxWithRetractAggFunctionTestBase
<
Decimal
>
{
public
static
final
class
DecimalMaxWithRetractAggFunctionTest
extends
MaxWithRetractAggFunctionTestBase
<
Decimal
>
{
private
int
precision
=
20
;
private
int
scale
=
6
;
...
...
@@ -395,7 +334,7 @@ public class MaxWithRetractAggFunctionTest {
/**
* Test for StringMaxWithRetractAggFunction.
*/
public
static
class
StringMaxWithRetractAggFunctionTest
extends
MaxWithRetractAggFunctionTestBase
<
BinaryString
>
{
public
static
final
class
StringMaxWithRetractAggFunctionTest
extends
MaxWithRetractAggFunctionTestBase
<
BinaryString
>
{
@Override
protected
List
<
List
<
BinaryString
>>
getInputValueSets
()
{
...
...
@@ -444,7 +383,7 @@ public class MaxWithRetractAggFunctionTest {
/**
* Test for TimestampMaxWithRetractAggFunction.
*/
public
static
class
TimestampMaxWithRetractAggFunctionTest
extends
MaxWithRetractAggFunctionTestBase
<
SqlTimestamp
>
{
public
static
final
class
TimestampMaxWithRetractAggFunctionTest
extends
MaxWithRetractAggFunctionTestBase
<
SqlTimestamp
>
{
@Override
protected
List
<
List
<
SqlTimestamp
>>
getInputValueSets
()
{
...
...
@@ -488,7 +427,7 @@ public class MaxWithRetractAggFunctionTest {
/**
* Test for TimestampMaxWithRetractAggFunction, precision is 9.
*/
public
static
class
Timestamp9MaxWithRetractAggFunctionTest
extends
MaxWithRetractAggFunctionTestBase
<
SqlTimestamp
>
{
public
static
final
class
Timestamp9MaxWithRetractAggFunctionTest
extends
MaxWithRetractAggFunctionTestBase
<
SqlTimestamp
>
{
@Override
protected
List
<
List
<
SqlTimestamp
>>
getInputValueSets
()
{
...
...
@@ -534,7 +473,7 @@ public class MaxWithRetractAggFunctionTest {
/**
* Test for DateMaxWithRetractAggFunction.
*/
public
static
class
DateMaxWithRetractAggFunctionTest
extends
MaxWithRetractAggFunctionTestBase
<
Date
>
{
public
static
final
class
DateMaxWithRetractAggFunctionTest
extends
MaxWithRetractAggFunctionTestBase
<
Date
>
{
@Override
protected
List
<
List
<
Date
>>
getInputValueSets
()
{
...
...
@@ -578,7 +517,7 @@ public class MaxWithRetractAggFunctionTest {
/**
* Test for TimeMaxWithRetractAggFunction.
*/
public
static
class
TimeMaxWithRetractAggFunctionTest
extends
MaxWithRetractAggFunctionTestBase
<
Time
>
{
public
static
final
class
TimeMaxWithRetractAggFunctionTest
extends
MaxWithRetractAggFunctionTestBase
<
Time
>
{
@Override
protected
List
<
List
<
Time
>>
getInputValueSets
()
{
...
...
@@ -618,4 +557,80 @@ public class MaxWithRetractAggFunctionTest {
return
new
TimeMaxWithRetractAggFunction
();
}
}
// --------------------------------------------------------------------------------------------
// This section contain base classes that provide:
// - common inputs
// - declare the accumulator class
// - accessor for retract function
// for tests declared above.
// --------------------------------------------------------------------------------------------
/**
* The base test class for MaxWithRetractAggFunction.
*/
public
abstract
static
class
MaxWithRetractAggFunctionTestBase
<
T
>
extends
AggFunctionTestBase
<
T
,
MaxWithRetractAccumulator
<
T
>>
{
@Override
protected
Class
<?>
getAccClass
()
{
return
MaxWithRetractAccumulator
.
class
;
}
@Override
protected
Method
getRetractFunc
()
throws
NoSuchMethodException
{
return
getAggregator
().
getClass
().
getMethod
(
"retract"
,
getAccClass
(),
Object
.
class
);
}
}
/**
* Test MaxWithRetractAggFunction for number type.
*/
public
abstract
static
class
NumberMaxWithRetractAggFunctionTest
<
T
>
extends
MaxWithRetractAggFunctionTestBase
<
T
>
{
protected
abstract
T
getMinValue
();
protected
abstract
T
getMaxValue
();
protected
abstract
T
getValue
(
String
v
);
@Override
protected
List
<
List
<
T
>>
getInputValueSets
()
{
return
Arrays
.
asList
(
Arrays
.
asList
(
getValue
(
"1"
),
null
,
getMaxValue
(),
getValue
(
"-99"
),
getValue
(
"3"
),
getValue
(
"56"
),
getValue
(
"0"
),
getMinValue
(),
getValue
(
"-20"
),
getValue
(
"17"
),
null
),
Arrays
.
asList
(
null
,
null
,
null
,
null
,
null
,
null
),
Arrays
.
asList
(
null
,
getValue
(
"10"
)
)
);
}
@Override
protected
List
<
T
>
getExpectedResults
()
{
return
Arrays
.
asList
(
getMaxValue
(),
null
,
getValue
(
"10"
)
);
}
}
}
flink-table/flink-table-planner-blink/src/test/java/org/apache/flink/table/planner/functions/aggfunctions/MinWithRetractAggFunctionTest.java
浏览文件 @
b3c86a81
...
...
@@ -50,80 +50,19 @@ import java.util.List;
* Test case for built-in Min with retraction aggregate function.
*/
@RunWith
(
Enclosed
.
class
)
public
class
MinWithRetractAggFunctionTest
{
public
final
class
MinWithRetractAggFunctionTest
{
/**
* The base test class for MinWithRetractAggFunction.
*/
public
abstract
static
class
MinWithRetractAggFunctionTestBase
<
T
>
extends
AggFunctionTestBase
<
T
,
MinWithRetractAccumulator
<
T
>>
{
@Override
protected
Class
<?>
getAccClass
()
{
return
MinWithRetractAccumulator
.
class
;
}
@Override
protected
Method
getRetractFunc
()
throws
NoSuchMethodException
{
return
getAggregator
().
getClass
().
getMethod
(
"retract"
,
getAccClass
(),
Object
.
class
);
}
}
/**
* Test MinWithRetractAggFunction for number type.
*/
public
abstract
static
class
NumberMinWithRetractAggFunctionTestBase
<
T
>
extends
MinWithRetractAggFunctionTestBase
<
T
>
{
protected
abstract
T
getMinValue
();
protected
abstract
T
getMaxValue
();
protected
abstract
T
getValue
(
String
v
);
@Override
protected
List
<
List
<
T
>>
getInputValueSets
()
{
return
Arrays
.
asList
(
Arrays
.
asList
(
getValue
(
"1"
),
null
,
getMaxValue
(),
getValue
(
"-99"
),
getValue
(
"3"
),
getValue
(
"56"
),
getValue
(
"0"
),
getMinValue
(),
getValue
(
"-20"
),
getValue
(
"17"
),
null
),
Arrays
.
asList
(
null
,
null
,
null
,
null
,
null
,
null
),
Arrays
.
asList
(
null
,
getValue
(
"10"
)
)
);
}
@Override
protected
List
<
T
>
getExpectedResults
()
{
return
Arrays
.
asList
(
getMinValue
(),
null
,
getValue
(
"10"
)
);
}
}
// --------------------------------------------------------------------------------------------
// Test sets for a particular type being aggregated
//
// Actual tests are implemented in:
// - AggFunctionTestBase
// --------------------------------------------------------------------------------------------
/**
* Test for ByteMinWithRetractAggFunction.
*/
public
static
class
ByteMinWithRetractAggFunctionTest
extends
NumberMinWithRetractAggFunctionTestBase
<
Byte
>
{
public
static
final
class
ByteMinWithRetractAggFunctionTest
extends
NumberMinWithRetractAggFunctionTestBase
<
Byte
>
{
@Override
protected
Byte
getMinValue
()
{
...
...
@@ -149,7 +88,7 @@ public class MinWithRetractAggFunctionTest {
/**
* Test for ShortMinWithRetractAggFunction.
*/
public
static
class
ShortMinWithRetractAggFunctionTest
extends
NumberMinWithRetractAggFunctionTestBase
<
Short
>
{
public
static
final
class
ShortMinWithRetractAggFunctionTest
extends
NumberMinWithRetractAggFunctionTestBase
<
Short
>
{
@Override
protected
Short
getMinValue
()
{
...
...
@@ -175,7 +114,7 @@ public class MinWithRetractAggFunctionTest {
/**
* Test for IntMinWithRetractAggFunction.
*/
public
static
class
IntMinWithRetractAggFunctionTest
extends
NumberMinWithRetractAggFunctionTestBase
<
Integer
>
{
public
static
final
class
IntMinWithRetractAggFunctionTest
extends
NumberMinWithRetractAggFunctionTestBase
<
Integer
>
{
@Override
protected
Integer
getMinValue
()
{
...
...
@@ -201,7 +140,7 @@ public class MinWithRetractAggFunctionTest {
/**
* Test for LongMinWithRetractAggFunction.
*/
public
static
class
LongMinWithRetractAggFunctionTest
extends
NumberMinWithRetractAggFunctionTestBase
<
Long
>
{
public
static
final
class
LongMinWithRetractAggFunctionTest
extends
NumberMinWithRetractAggFunctionTestBase
<
Long
>
{
@Override
protected
Long
getMinValue
()
{
...
...
@@ -227,7 +166,7 @@ public class MinWithRetractAggFunctionTest {
/**
* Test for FloatMinWithRetractAggFunction.
*/
public
static
class
FloatMinWithRetractAggFunctionTest
extends
NumberMinWithRetractAggFunctionTestBase
<
Float
>
{
public
static
final
class
FloatMinWithRetractAggFunctionTest
extends
NumberMinWithRetractAggFunctionTestBase
<
Float
>
{
@Override
protected
Float
getMinValue
()
{
...
...
@@ -253,7 +192,7 @@ public class MinWithRetractAggFunctionTest {
/**
* Test for DoubleMinWithRetractAggFunction.
*/
public
static
class
DoubleMinWithRetractAggFunctionTest
extends
NumberMinWithRetractAggFunctionTestBase
<
Double
>
{
public
static
final
class
DoubleMinWithRetractAggFunctionTest
extends
NumberMinWithRetractAggFunctionTestBase
<
Double
>
{
@Override
protected
Double
getMinValue
()
{
...
...
@@ -279,7 +218,7 @@ public class MinWithRetractAggFunctionTest {
/**
* Test for BooleanMinWithRetractAggFunction.
*/
public
static
class
BooleanMinWithRetractAggFunctionTest
extends
MinWithRetractAggFunctionTestBase
<
Boolean
>
{
public
static
final
class
BooleanMinWithRetractAggFunctionTest
extends
MinWithRetractAggFunctionTestBase
<
Boolean
>
{
@Override
protected
List
<
List
<
Boolean
>>
getInputValueSets
()
{
...
...
@@ -334,7 +273,7 @@ public class MinWithRetractAggFunctionTest {
/**
* Test for DecimalMinWithRetractAggFunction.
*/
public
static
class
DecimalMinWithRetractAggFunctionTest
extends
MinWithRetractAggFunctionTestBase
<
Decimal
>
{
public
static
final
class
DecimalMinWithRetractAggFunctionTest
extends
MinWithRetractAggFunctionTestBase
<
Decimal
>
{
private
int
precision
=
20
;
private
int
scale
=
6
;
...
...
@@ -385,7 +324,7 @@ public class MinWithRetractAggFunctionTest {
/**
* Test for StringMinWithRetractAggFunction.
*/
public
static
class
StringMinWithRetractAggFunctionTest
public
static
final
class
StringMinWithRetractAggFunctionTest
extends
MinWithRetractAggFunctionTestBase
<
BinaryString
>
{
@Override
...
...
@@ -435,7 +374,7 @@ public class MinWithRetractAggFunctionTest {
/**
* Test for TimestampMinWithRetractAggFunction.
*/
public
static
class
TimestampMinWithRetractAggFunctionTest
public
static
final
class
TimestampMinWithRetractAggFunctionTest
extends
MinWithRetractAggFunctionTestBase
<
SqlTimestamp
>
{
@Override
...
...
@@ -480,7 +419,7 @@ public class MinWithRetractAggFunctionTest {
/**
* Test for TimestampMinWithRetractAggFunction, precision is 9.
*/
public
static
class
Timestamp9MinWithRetractAggFunctionTest
public
static
final
class
Timestamp9MinWithRetractAggFunctionTest
extends
MinWithRetractAggFunctionTestBase
<
SqlTimestamp
>
{
@Override
...
...
@@ -527,7 +466,7 @@ public class MinWithRetractAggFunctionTest {
/**
* Test for DateMinWithRetractAggFunction.
*/
public
static
class
DateMinWithRetractAggFunctionTest
extends
MinWithRetractAggFunctionTestBase
<
Date
>
{
public
static
final
class
DateMinWithRetractAggFunctionTest
extends
MinWithRetractAggFunctionTestBase
<
Date
>
{
@Override
protected
List
<
List
<
Date
>>
getInputValueSets
()
{
...
...
@@ -571,7 +510,7 @@ public class MinWithRetractAggFunctionTest {
/**
* Test for TimeMinWithRetractAggFunction.
*/
public
static
class
TimeMinWithRetractAggFunctionTest
extends
MinWithRetractAggFunctionTestBase
<
Time
>
{
public
static
final
class
TimeMinWithRetractAggFunctionTest
extends
MinWithRetractAggFunctionTestBase
<
Time
>
{
@Override
protected
List
<
List
<
Time
>>
getInputValueSets
()
{
...
...
@@ -611,4 +550,80 @@ public class MinWithRetractAggFunctionTest {
return
new
TimeMinWithRetractAggFunction
();
}
}
// --------------------------------------------------------------------------------------------
// This section contain base classes that provide:
// - common inputs
// - declare the accumulator class
// - accessor for retract function
// for tests declared above.
// --------------------------------------------------------------------------------------------
/**
* The base test class for MinWithRetractAggFunction.
*/
public
abstract
static
class
MinWithRetractAggFunctionTestBase
<
T
>
extends
AggFunctionTestBase
<
T
,
MinWithRetractAccumulator
<
T
>>
{
@Override
protected
Class
<?>
getAccClass
()
{
return
MinWithRetractAccumulator
.
class
;
}
@Override
protected
Method
getRetractFunc
()
throws
NoSuchMethodException
{
return
getAggregator
().
getClass
().
getMethod
(
"retract"
,
getAccClass
(),
Object
.
class
);
}
}
/**
* Test MinWithRetractAggFunction for number type.
*/
public
abstract
static
class
NumberMinWithRetractAggFunctionTestBase
<
T
>
extends
MinWithRetractAggFunctionTestBase
<
T
>
{
protected
abstract
T
getMinValue
();
protected
abstract
T
getMaxValue
();
protected
abstract
T
getValue
(
String
v
);
@Override
protected
List
<
List
<
T
>>
getInputValueSets
()
{
return
Arrays
.
asList
(
Arrays
.
asList
(
getValue
(
"1"
),
null
,
getMaxValue
(),
getValue
(
"-99"
),
getValue
(
"3"
),
getValue
(
"56"
),
getValue
(
"0"
),
getMinValue
(),
getValue
(
"-20"
),
getValue
(
"17"
),
null
),
Arrays
.
asList
(
null
,
null
,
null
,
null
,
null
,
null
),
Arrays
.
asList
(
null
,
getValue
(
"10"
)
)
);
}
@Override
protected
List
<
T
>
getExpectedResults
()
{
return
Arrays
.
asList
(
getMinValue
(),
null
,
getValue
(
"10"
)
);
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录