Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
doujutun3207
flink
提交
2142eeda
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,发现更多精彩内容 >>
提交
2142eeda
编写于
12月 11, 2017
作者:
R
Rong Rong
提交者:
twalthr
12月 19, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[FLINK-8215] [table] Support implicit type widening for array/map constructors in SQL
This closes #5148.
上级
8aca84c7
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
28 addition
and
2 deletion
+28
-2
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/codegen/CodeGenerator.scala
.../scala/org/apache/flink/table/codegen/CodeGenerator.scala
+2
-2
flink-libraries/flink-table/src/test/scala/org/apache/flink/table/expressions/ArrayTypeTest.scala
...la/org/apache/flink/table/expressions/ArrayTypeTest.scala
+3
-0
flink-libraries/flink-table/src/test/scala/org/apache/flink/table/expressions/MapTypeTest.scala
...cala/org/apache/flink/table/expressions/MapTypeTest.scala
+3
-0
flink-libraries/flink-table/src/test/scala/org/apache/flink/table/expressions/validation/ArrayTypeValidationTest.scala
...able/expressions/validation/ArrayTypeValidationTest.scala
+10
-0
flink-libraries/flink-table/src/test/scala/org/apache/flink/table/expressions/validation/MapTypeValidationTest.scala
.../table/expressions/validation/MapTypeValidationTest.scala
+10
-0
未找到文件。
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/codegen/CodeGenerator.scala
浏览文件 @
2142eeda
...
...
@@ -1312,10 +1312,10 @@ abstract class CodeGenerator(
}
private
[
flink
]
def
generateNullableOutputBoxing
(
e
lement
:
GeneratedExpression
,
e
xpr
:
GeneratedExpression
,
typeInfo
:
TypeInformation
[
_
])
:
GeneratedExpression
=
{
val
boxedExpr
=
generateOutputFieldBoxing
(
element
)
val
boxedExpr
=
generateOutputFieldBoxing
(
generateCast
(
nullCheck
,
expr
,
typeInfo
)
)
val
boxedTypeTerm
=
boxedTypeTermForTypeInfo
(
typeInfo
)
val
exprOrNull
:
String
=
if
(
nullCheck
)
{
s
"${boxedExpr.nullTerm} ? null : ($boxedTypeTerm) ${boxedExpr.resultTerm}"
...
...
flink-libraries/flink-table/src/test/scala/org/apache/flink/table/expressions/ArrayTypeTest.scala
浏览文件 @
2142eeda
...
...
@@ -99,6 +99,9 @@ class ArrayTypeTest extends ArrayTypeTestBase {
"Array(Array(1, 2, 3), Array(3, 2, 1))"
,
"ARRAY[ARRAY[1, 2, 3], ARRAY[3, 2, 1]]"
,
"[[1, 2, 3], [3, 2, 1]]"
)
// implicit type cast only works on SQL APIs.
testSqlApi
(
"ARRAY[CAST(1 AS DOUBLE), CAST(2 AS FLOAT)]"
,
"[1.0, 2.0]"
)
}
@Test
...
...
flink-libraries/flink-table/src/test/scala/org/apache/flink/table/expressions/MapTypeTest.scala
浏览文件 @
2142eeda
...
...
@@ -77,6 +77,9 @@ class MapTypeTest extends MapTypeTestBase {
"map(2.0002p, 2.0003p)"
,
"MAP[CAST(2.0002 AS DECIMAL), CAST(2.0003 AS DECIMAL)]"
,
"{2.0002=2.0003}"
)
// implicit conversion
testSqlApi
(
"MAP['k1', CAST(1 AS DOUBLE), 'k2', CAST(2 AS FLOAT)]"
,
"{k1=1.0, k2=2.0}"
)
}
@Test
...
...
flink-libraries/flink-table/src/test/scala/org/apache/flink/table/expressions/validation/ArrayTypeValidationTest.scala
浏览文件 @
2142eeda
...
...
@@ -25,6 +25,16 @@ import org.junit.Test
class
ArrayTypeValidationTest
extends
ArrayTypeTestBase
{
@Test
(
expected
=
classOf
[
ValidationException
])
def
testImplicitTypeCastTableApi
()
:
Unit
=
{
testTableApi
(
array
(
1.0
,
2.0f
),
"FAIL"
,
"FAIL"
)
}
@Test
(
expected
=
classOf
[
ValidationException
])
def
testImplicitTypeCastArraySql
()
:
Unit
=
{
testSqlApi
(
"ARRAY['string', 12]"
,
"FAIL"
)
}
@Test
(
expected
=
classOf
[
ValidationException
])
def
testObviousInvalidIndexTableApi
()
:
Unit
=
{
testTableApi
(
'f2
.
at
(
0
),
"FAIL"
,
"FAIL"
)
...
...
flink-libraries/flink-table/src/test/scala/org/apache/flink/table/expressions/validation/MapTypeValidationTest.scala
浏览文件 @
2142eeda
...
...
@@ -44,4 +44,14 @@ class MapTypeValidationTest extends MapTypeTestBase {
def
testEmptyMap
()
:
Unit
=
{
testAllApis
(
"FAIL"
,
"map()"
,
"MAP[]"
,
"FAIL"
)
}
@Test
(
expected
=
classOf
[
ValidationException
])
def
testUnsupportedMapImplicitTypeCastTableApi
()
:
Unit
=
{
testTableApi
(
map
(
"k1"
,
1.0
,
"k2"
,
2.0f
),
"map('k1', 1.0, 'k2', 2.0f)"
,
"FAIL"
)
}
@Test
(
expected
=
classOf
[
ValidationException
])
def
testUnsupportedMapImplicitTypeCastSql
()
:
Unit
=
{
testSqlApi
(
"MAP['k1', 'string', 'k2', 12]"
,
"FAIL"
)
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录