danny0405 commented on a change in pull request #10224: [FLINK-14716][table-planner-blink] Cooperate computed column with push down rules URL: https://github.com/apache/flink/pull/10224#discussion_r347270034
########## File path: flink-table/flink-table-planner-blink/src/main/java/org/apache/flink/table/planner/catalog/CatalogSchemaTable.java ########## @@ -0,0 +1,212 @@ +/* + * 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.planner.catalog; + +import org.apache.flink.table.api.DataTypes; +import org.apache.flink.table.api.TableException; +import org.apache.flink.table.api.TableSchema; +import org.apache.flink.table.api.ValidationException; +import org.apache.flink.table.catalog.Catalog; +import org.apache.flink.table.catalog.CatalogBaseTable; +import org.apache.flink.table.catalog.CatalogTable; +import org.apache.flink.table.catalog.ConnectorCatalogTable; +import org.apache.flink.table.catalog.ObjectIdentifier; +import org.apache.flink.table.catalog.ObjectPath; +import org.apache.flink.table.catalog.QueryOperationCatalogView; +import org.apache.flink.table.catalog.exceptions.TableNotExistException; +import org.apache.flink.table.catalog.stats.CatalogColumnStatistics; +import org.apache.flink.table.catalog.stats.CatalogTableStatistics; +import org.apache.flink.table.plan.stats.TableStats; +import org.apache.flink.table.planner.calcite.FlinkTypeFactory; +import org.apache.flink.table.planner.plan.stats.FlinkStatistic; +import org.apache.flink.table.planner.sources.TableSourceUtil; +import org.apache.flink.table.planner.utils.JavaScalaConversionUtil; +import org.apache.flink.table.runtime.types.LogicalTypeDataTypeConverter; +import org.apache.flink.table.types.DataType; +import org.apache.flink.table.types.logical.LogicalType; +import org.apache.flink.table.types.logical.TimestampKind; +import org.apache.flink.table.types.logical.TimestampType; + +import org.apache.calcite.rel.type.RelDataType; +import org.apache.calcite.rel.type.RelDataTypeFactory; +import org.apache.calcite.schema.TemporalTable; +import org.apache.calcite.schema.impl.AbstractTable; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +import scala.Option; + +import static java.lang.String.format; +import static org.apache.flink.table.util.CatalogTableStatisticsConverter.convertToTableStats; + +/** + * Represents a wrapper for {@link CatalogBaseTable} in {@link org.apache.calcite.schema.Schema}. + * + * <p>This table would be converted to + * {@link org.apache.flink.table.planner.plan.schema.FlinkPreparingTableBase} + * based on its internal source type during sql-to-rel conversion. + * + * <p>See + * {@link org.apache.flink.table.planner.plan.FlinkCalciteCatalogReader#getTable(List)} + * for details. + */ +public class CatalogSchemaTable extends AbstractTable implements TemporalTable { + //~ Instance fields -------------------------------------------------------- + + private final ObjectIdentifier tableIdentifier; + private final Catalog catalog; Review comment: The catalog holds 3 infos that we need: 1. TableStats 2. Column stats 3. TableFactory The CatalogSchemaTable is just a temp object, reference the Catalog make it looks more clear, and we can extend it more easier if we need more info from the catalog. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
