[ 
https://issues.apache.org/jira/browse/FLINK-7636?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16175090#comment-16175090
 ] 

ASF GitHub Bot commented on FLINK-7636:
---------------------------------------

Github user fhueske commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4681#discussion_r140291045
  
    --- Diff: 
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/plan/schema/FlinkRelOptTable.scala
 ---
    @@ -0,0 +1,265 @@
    +/*
    + * 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.plan.schema
    +
    +import org.apache.calcite.plan.{RelOptCluster, RelOptSchema, RelOptTable}
    +import org.apache.calcite.rel.`type`.RelDataType
    +import org.apache.calcite.prepare.CalcitePrepareImpl
    +import java.util.{List => JList}
    +
    +import com.google.common.collect.ImmutableList
    +import org.apache.calcite.adapter.enumerable.EnumerableTableScan
    +import org.apache.calcite.linq4j.tree.Expression
    +import org.apache.calcite.plan.RelOptTable.ToRelContext
    +import org.apache.calcite.prepare.Prepare.PreparingTable
    +import org.apache.calcite.rel.`type`.{RelDataTypeField, RelDataTypeFactory}
    +import org.apache.calcite.rel._
    +import org.apache.calcite.rel.logical.LogicalTableScan
    +import org.apache.calcite.runtime.Hook
    +import org.apache.calcite.schema.{StreamableTable, TranslatableTable}
    +import org.apache.calcite.sql.SqlAccessType
    +import org.apache.calcite.sql.validate.{SqlModality, SqlMonotonicity}
    +import org.apache.calcite.sql2rel.InitializerContext
    +import org.apache.calcite.util.ImmutableBitSet
    +import org.apache.flink.table.plan.stats.FlinkStatistic
    +
    +import scala.collection.JavaConverters._
    +
    +/**
    +  * FlinkRelOptTable wraps a FlinkTable
    +  *
    +  * @param schema  the [[RelOptSchema]] this table belongs to
    +  * @param rowType the type of rows returned by this table
    +  * @param names   the identifier for this table. The identifier must be 
unique with
    +  *                respect to the Connection producing this table.
    +  * @param table   wrapped flink table
    +  */
    +
    +class FlinkRelOptTable protected(
    +    schema: RelOptSchema,
    +    rowType: RelDataType,
    +    names: JList[String],
    +    table: FlinkTable[_]) extends PreparingTable {
    +
    +  /**
    +    * Creates a copy of this Flink RelOptTable with new Flink Table and 
new row type.
    +    *
    +    * @param newTable    new flink table
    +    * @param typeFactory type factory to create new row type of new flink 
table
    +    * @return The copy of this Flink RelOptTable with new Flink table and 
new row type
    +    */
    +  def copy(newTable: FlinkTable[_], typeFactory: RelDataTypeFactory): 
FlinkRelOptTable = {
    +    val newRowType = newTable.getRowType(typeFactory)
    +    FlinkRelOptTable.create(schema, newRowType, names, newTable)
    +  }
    +
    +  /**
    +    * Extends a table with the given extra fields, which is not supported 
now.
    +    *
    +    * @param extendedFields
    --- End diff --
    
    Remove is no parameter description is provided


> Introduce Flink RelOptTable,  and remove tableSource from all TableSourceScan 
> node constructor
> ----------------------------------------------------------------------------------------------
>
>                 Key: FLINK-7636
>                 URL: https://issues.apache.org/jira/browse/FLINK-7636
>             Project: Flink
>          Issue Type: Improvement
>          Components: Table API & SQL
>            Reporter: jingzhang
>            Assignee: jingzhang
>
> At present, there are two ways to fetch TableSource of a TableSourceScan node 
> (e.g LogicalTableSourceScan, PhysicalTableSourceScan ...):
> 1. 
> {code}
> val relOptTable: RelOptTable = getTable()
> val tableSourceTable = relOptTable.unwrap(classOf[TableSourceTable[_]])
> val tableSouce = tableSourceTable.tableSource
> {code}
> the result of getTable() is instance of RelOptTableImpl now, and it will not 
> change after RelNode tree is built.
> 2. now all TableSourceScan contains a tablesource as constructor parameter, 
> so we could fetch the tablesource directly later.
>  
> The result tableSource is different with each other by above two ways after 
> apply project push(PPD) down or filter push down(FPD).  It is very confusing. 
> we hope to fix the problem by introducing FlinkRelOptTable to replace 
> RelOptTableImpl, and remove tableSource parameter from TableSourceScan's 
> constructor. After PPD or FPD,  a new FlinkRelOptTable instance which 
> contains a new TableSourceTable will be passed to TableSourceScan 
> constructor. 



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to