KurtYoung commented on a change in pull request #7993: [FLINK-11932] [table-planner-blink] Add support for generating optimized logical plan for 'select * from mytable' URL: https://github.com/apache/flink/pull/7993#discussion_r266236634
########## File path: flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/calcite/CalciteConfig.scala ########## @@ -0,0 +1,227 @@ +/* + * 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.flink.table.plan.optimize.program.{BatchOptimizeContext, FlinkChainedProgram, StreamOptimizeContext} +import org.apache.flink.util.Preconditions + +import org.apache.calcite.config.{CalciteConnectionConfig, CalciteConnectionConfigImpl, CalciteConnectionProperty} +import org.apache.calcite.sql.SqlOperatorTable +import org.apache.calcite.sql.parser.SqlParser +import org.apache.calcite.sql.util.ChainedSqlOperatorTable +import org.apache.calcite.sql2rel.SqlToRelConverter + +import java.util.Properties + +/** + * Builder for creating a Calcite configuration. + */ +class CalciteConfigBuilder { + + /** + * Defines the optimize program for batch table plan. + */ + private var batchProgram: Option[FlinkChainedProgram[BatchOptimizeContext]] = None + + /** + * Defines the optimize program for stream table plan. + */ + private var streamProgram: Option[FlinkChainedProgram[StreamOptimizeContext]] = None + + /** + * Defines the SQL operator tables. + */ + private var replaceOperatorTable: Boolean = false + private var operatorTables: List[SqlOperatorTable] = Nil + + /** + * Replaces the default batch table optimize program with the given program. + */ + def replaceBatchProgram( + program: FlinkChainedProgram[BatchOptimizeContext]): CalciteConfigBuilder = { + Preconditions.checkNotNull(program) + batchProgram = Some(program) + this + } + + /** + * Replaces the default stream table optimize program with the given program. + */ + def replaceStreamProgram( + program: FlinkChainedProgram[StreamOptimizeContext]): CalciteConfigBuilder = { + Preconditions.checkNotNull(program) + streamProgram = Some(program) + this + } + + /** + * Defines a SQL parser configuration. + */ + private var replaceSqlParserConfig: Option[SqlParser.Config] = None Review comment: move variables to stay together, so as functions ---------------------------------------------------------------- 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
