Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
doujutun3207
flink
提交
86d32ac8
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,发现更多精彩内容 >>
提交
86d32ac8
编写于
3月 19, 2017
作者:
J
jingzhang
提交者:
twalthr
3月 21, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[FLINK-6037] [table] Metadata provider didn't work in SQL
This closes #3559.
上级
ffb05607
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
46 addition
and
8 deletion
+46
-8
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/calcite/FlinkPlannerImpl.scala
...ala/org/apache/flink/table/calcite/FlinkPlannerImpl.scala
+3
-2
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/calcite/FlinkRelBuilder.scala
...cala/org/apache/flink/table/calcite/FlinkRelBuilder.scala
+1
-6
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/calcite/FlinkRelOptClusterFactory.scala
...pache/flink/table/calcite/FlinkRelOptClusterFactory.scala
+42
-0
未找到文件。
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/calcite/FlinkPlannerImpl.scala
浏览文件 @
86d32ac8
...
...
@@ -36,6 +36,7 @@ import org.apache.calcite.sql2rel.{SqlRexConvertletTable, SqlToRelConverter}
import
org.apache.calcite.tools.
{
FrameworkConfig
,
RelConversionException
}
import
org.apache.flink.table.api.
{
SqlParserException
,
TableException
,
ValidationException
}
import
org.apache.flink.table.calcite.sql2rel.FlinkRelDecorrelator
import
org.apache.flink.table.plan.cost.FlinkDefaultRelMetadataProvider
import
scala.collection.JavaConversions._
...
...
@@ -99,7 +100,7 @@ class FlinkPlannerImpl(
try
{
assert
(
validatedSqlNode
!=
null
)
val
rexBuilder
:
RexBuilder
=
createRexBuilder
val
cluster
:
RelOptCluster
=
RelOptCluster
.
create
(
planner
,
rexBuilder
)
val
cluster
:
RelOptCluster
=
FlinkRelOptClusterFactory
.
create
(
planner
,
rexBuilder
)
val
config
=
SqlToRelConverter
.
configBuilder
()
.
withTrimUnusedFields
(
false
).
withConvertTableAccess
(
false
).
build
()
val
sqlToRelConverter
:
SqlToRelConverter
=
new
SqlToRelConverter
(
...
...
@@ -140,7 +141,7 @@ class FlinkPlannerImpl(
validator
.
setIdentifierExpansion
(
true
)
val
validatedSqlNode
:
SqlNode
=
validator
.
validate
(
sqlNode
)
val
rexBuilder
:
RexBuilder
=
createRexBuilder
val
cluster
:
RelOptCluster
=
RelOptCluster
.
create
(
planner
,
rexBuilder
)
val
cluster
:
RelOptCluster
=
FlinkRelOptClusterFactory
.
create
(
planner
,
rexBuilder
)
val
config
:
SqlToRelConverter.Config
=
SqlToRelConverter
.
configBuilder
.
withTrimUnusedFields
(
false
).
withConvertTableAccess
(
false
).
build
val
sqlToRelConverter
:
SqlToRelConverter
=
new
SqlToRelConverter
(
...
...
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/calcite/FlinkRelBuilder.scala
浏览文件 @
86d32ac8
...
...
@@ -84,12 +84,7 @@ object FlinkRelBuilder {
val
planner
=
new
VolcanoPlanner
(
config
.
getCostFactory
,
Contexts
.
empty
())
planner
.
setExecutor
(
config
.
getExecutor
)
planner
.
addRelTraitDef
(
ConventionTraitDef
.
INSTANCE
)
val
cluster
=
RelOptCluster
.
create
(
planner
,
new
RexBuilder
(
typeFactory
))
cluster
.
setMetadataProvider
(
FlinkDefaultRelMetadataProvider
.
INSTANCE
)
// just set metadataProvider is not enough, see
// https://www.mail-archive.com/dev@calcite.apache.org/msg00930.html
RelMetadataQuery
.
THREAD_PROVIDERS
.
set
(
JaninoRelMetadataProvider
.
of
(
cluster
.
getMetadataProvider
))
val
cluster
=
FlinkRelOptClusterFactory
.
create
(
planner
,
new
RexBuilder
(
typeFactory
))
val
calciteSchema
=
CalciteSchema
.
from
(
config
.
getDefaultSchema
)
val
relOptSchema
=
new
CalciteCatalogReader
(
calciteSchema
,
...
...
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/calcite/FlinkRelOptClusterFactory.scala
0 → 100644
浏览文件 @
86d32ac8
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.apache.flink.table.calcite
import
org.apache.calcite.plan.
{
RelOptCluster
,
RelOptPlanner
}
import
org.apache.calcite.rel.metadata.
{
DefaultRelMetadataProvider
,
JaninoRelMetadataProvider
,
RelMetadataQuery
}
import
org.apache.calcite.rex.RexBuilder
import
org.apache.flink.table.plan.cost.FlinkDefaultRelMetadataProvider
/**
* The utility class is to create special [[RelOptCluster]] instance which use
* [[FlinkDefaultRelMetadataProvider]] instead of [[DefaultRelMetadataProvider]].
*/
object
FlinkRelOptClusterFactory
{
def
create
(
planner
:
RelOptPlanner
,
rexBuilder
:
RexBuilder
)
:
RelOptCluster
=
{
val
cluster
=
RelOptCluster
.
create
(
planner
,
rexBuilder
)
cluster
.
setMetadataProvider
(
FlinkDefaultRelMetadataProvider
.
INSTANCE
)
// just set metadataProvider is not enough, see
// https://www.mail-archive.com/dev@calcite.apache.org/msg00930.html
RelMetadataQuery
.
THREAD_PROVIDERS
.
set
(
JaninoRelMetadataProvider
.
of
(
cluster
.
getMetadataProvider
))
cluster
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录