Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
doujutun3207
flink
提交
9849a576
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,发现更多精彩内容 >>
提交
9849a576
编写于
12月 02, 2015
作者:
C
chengxiang li
提交者:
twalthr
12月 03, 2015
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[FLINK-3098] [Table API] Cast Data to Long throw compile error.
This closes #1431.
上级
8bd98e09
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
40 addition
and
1 deletion
+40
-1
flink-staging/flink-table/src/main/scala/org/apache/flink/api/table/codegen/ExpressionCodeGenerator.scala
...che/flink/api/table/codegen/ExpressionCodeGenerator.scala
+1
-1
flink-staging/flink-table/src/test/java/org/apache/flink/api/java/table/test/CastingITCase.java
...a/org/apache/flink/api/java/table/test/CastingITCase.java
+22
-0
flink-staging/flink-table/src/test/scala/org/apache/flink/api/scala/table/test/CastingITCase.scala
...org/apache/flink/api/scala/table/test/CastingITCase.scala
+17
-0
未找到文件。
flink-staging/flink-table/src/main/scala/org/apache/flink/api/table/codegen/ExpressionCodeGenerator.scala
浏览文件 @
9849a576
...
@@ -409,7 +409,7 @@ abstract class ExpressionCodeGenerator[R](
...
@@ -409,7 +409,7 @@ abstract class ExpressionCodeGenerator[R](
"""
.
stripMargin
"""
.
stripMargin
}
else
{
}
else
{
s
"""
s
"""
|$resultTerm = ${childGen.resultTerm}.getTime();
|$resultT
pe $resultT
erm = ${childGen.resultTerm}.getTime();
"""
.
stripMargin
"""
.
stripMargin
}
}
childGen
.
code
+
castCode
childGen
.
code
+
castCode
...
...
flink-staging/flink-table/src/test/java/org/apache/flink/api/java/table/test/CastingITCase.java
浏览文件 @
9849a576
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
package
org.apache.flink.api.java.table.test
;
package
org.apache.flink.api.java.table.test
;
import
org.apache.flink.api.java.tuple.Tuple2
;
import
org.apache.flink.api.java.tuple.Tuple3
;
import
org.apache.flink.api.java.tuple.Tuple3
;
import
org.apache.flink.api.java.tuple.Tuple4
;
import
org.apache.flink.api.java.tuple.Tuple4
;
import
org.apache.flink.api.table.Table
;
import
org.apache.flink.api.table.Table
;
...
@@ -145,5 +146,26 @@ public class CastingITCase extends MultipleProgramsTestBase {
...
@@ -145,5 +146,26 @@ public class CastingITCase extends MultipleProgramsTestBase {
"1970-01-17 17:47:53.775\n"
;
"1970-01-17 17:47:53.775\n"
;
compareResultAsText
(
results
,
expected
);
compareResultAsText
(
results
,
expected
);
}
}
@Test
public
void
testCastDateToStringAndLong
()
throws
Exception
{
ExecutionEnvironment
env
=
ExecutionEnvironment
.
getExecutionEnvironment
();
TableEnvironment
tableEnv
=
new
TableEnvironment
();
DataSource
<
Tuple2
<
String
,
String
>>
input
=
env
.
fromElements
(
new
Tuple2
<>(
"2011-05-03 15:51:36.000"
,
"1304437896000"
));
Table
table
=
tableEnv
.
fromDataSet
(
input
);
Table
result
=
table
.
select
(
"f0.cast(DATE) AS f0, f1.cast(DATE) AS f1"
)
.
select
(
"f0.cast(STRING), f0.cast(LONG), f1.cast(STRING), f1.cast(LONG)"
);
DataSet
<
Row
>
ds
=
tableEnv
.
toDataSet
(
result
,
Row
.
class
);
List
<
Row
>
results
=
ds
.
collect
();
String
expected
=
"2011-05-03 15:51:36.000,1304437896000,2011-05-03 15:51:36.000,1304437896000\n"
;
compareResultAsText
(
results
,
expected
);
}
}
}
flink-staging/flink-table/src/test/scala/org/apache/flink/api/scala/table/test/CastingITCase.scala
浏览文件 @
9849a576
...
@@ -105,4 +105,21 @@ class CastingITCase(mode: TestExecutionMode) extends MultipleProgramsTestBase(mo
...
@@ -105,4 +105,21 @@ class CastingITCase(mode: TestExecutionMode) extends MultipleProgramsTestBase(mo
TestBaseUtils
.
compareResultAsText
(
results
.
asJava
,
expected
)
TestBaseUtils
.
compareResultAsText
(
results
.
asJava
,
expected
)
}
}
@Test
def
testCastDateToStringAndLong
{
val
env
:
ExecutionEnvironment
=
ExecutionEnvironment
.
getExecutionEnvironment
val
ds
=
env
.
fromElements
((
"2011-05-03 15:51:36.000"
,
"1304437896000"
))
val
result
=
ds
.
toTable
.
select
(
'_1
.
cast
(
BasicTypeInfo
.
DATE_TYPE_INFO
).
as
(
'f0
),
'_2
.
cast
(
BasicTypeInfo
.
DATE_TYPE_INFO
).
as
(
'f1
))
.
select
(
'f0
.
cast
(
BasicTypeInfo
.
STRING_TYPE_INFO
),
'f0
.
cast
(
BasicTypeInfo
.
LONG_TYPE_INFO
),
'f1
.
cast
(
BasicTypeInfo
.
STRING_TYPE_INFO
),
'f1
.
cast
(
BasicTypeInfo
.
LONG_TYPE_INFO
))
.
toDataSet
[
Row
]
.
collect
val
expected
=
"2011-05-03 15:51:36.000,1304437896000,"
+
"2011-05-03 15:51:36.000,1304437896000\n"
TestBaseUtils
.
compareResultAsText
(
result
.
asJava
,
expected
)
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录