[GitHub] godfreyhe commented on a change in pull request #7834: [FLINK-11715][table-planner-blink] Add optimize program to organize optimization phases
godfreyhe commented on a change in pull request #7834: [FLINK-11715][table-planner-blink] Add optimize program to organize optimization phases URL: https://github.com/apache/flink/pull/7834#discussion_r261471649 ## File path: flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/plan/optimize/program/OptimizeContext.scala ## @@ -0,0 +1,37 @@ +/* + * 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.optimize.program + +import org.apache.calcite.plan.{Context, RelOptPlanner} + +/** + * A OptimizeContext allows to obtain table environment information when optimizing. + */ +trait OptimizeContext { + + /** +* Gets the Calcite [[Context]] defined in [[org.apache.flink.table.api.TableEnvironment]]. +*/ + def getContext: Context Review comment: Yes, it's more clear than before that `OptimizeContext` extends Calcite's `Context` and exposes meaningful APIs. `BatchOptimizeContext` and `StreamOptimizeContext` can be unified after table environments have been unified. We can do this later. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] godfreyhe commented on a change in pull request #7834: [FLINK-11715][table-planner-blink] Add optimize program to organize optimization phases
godfreyhe commented on a change in pull request #7834: [FLINK-11715][table-planner-blink] Add optimize program to organize optimization phases URL: https://github.com/apache/flink/pull/7834#discussion_r261209978 ## File path: flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/plan/optimize/program/OptimizeContext.scala ## @@ -0,0 +1,37 @@ +/* + * 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.optimize.program + +import org.apache.calcite.plan.{Context, RelOptPlanner} + +/** + * A OptimizeContext allows to obtain table environment information when optimizing. + */ +trait OptimizeContext { + + /** +* Gets the Calcite [[Context]] defined in [[org.apache.flink.table.api.TableEnvironment]]. +*/ + def getContext: Context Review comment: A empty `Context` will be created in `AbstractRelOptPlanner` if building a `HepPlanner` without `Context`. And the rules executed in `HepPlanner` can not get `TableConfig` or ` FunctionCatalog` instances set by user. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] godfreyhe commented on a change in pull request #7834: [FLINK-11715][table-planner-blink] Add optimize program to organize optimization phases
godfreyhe commented on a change in pull request #7834: [FLINK-11715][table-planner-blink] Add optimize program to organize optimization phases URL: https://github.com/apache/flink/pull/7834#discussion_r261170460 ## File path: flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/plan/optimize/program/OptimizeContext.scala ## @@ -0,0 +1,37 @@ +/* + * 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.optimize.program + +import org.apache.calcite.plan.{Context, RelOptPlanner} + +/** + * A OptimizeContext allows to obtain table environment information when optimizing. + */ +trait OptimizeContext { + + /** +* Gets the Calcite [[Context]] defined in [[org.apache.flink.table.api.TableEnvironment]]. +*/ + def getContext: Context Review comment: For most of programs, they need not to know the content in the `Context`. The `Context` instance is only be used to create `HepPlanner` as a whole instance now: `new HepPlanner(hepProgram, context.getContext)`. Calcite's `Context` is built in `TableEnvironment` now, and `VolcanoPlanner` and `HepPlanner` are built with this context instance. However they are built in difference places, `VolcanoPlanner` is built in `FlinkRelBuilder` and `HepPlanner` is built in `FlinkHepProgram`. What I'm worried about is someone may be forget to modify `FlinkHepProgram` when he/she wants to extend `Context` in `TableEnvironment`. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] godfreyhe commented on a change in pull request #7834: [FLINK-11715][table-planner-blink] Add optimize program to organize optimization phases
godfreyhe commented on a change in pull request #7834: [FLINK-11715][table-planner-blink] Add optimize program to organize optimization phases URL: https://github.com/apache/flink/pull/7834#discussion_r261170460 ## File path: flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/plan/optimize/program/OptimizeContext.scala ## @@ -0,0 +1,37 @@ +/* + * 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.optimize.program + +import org.apache.calcite.plan.{Context, RelOptPlanner} + +/** + * A OptimizeContext allows to obtain table environment information when optimizing. + */ +trait OptimizeContext { + + /** +* Gets the Calcite [[Context]] defined in [[org.apache.flink.table.api.TableEnvironment]]. +*/ + def getContext: Context Review comment: For most of program, they need not to know the content in the `Context`. The `Context` instance is only be used to create `HepPlanner` as a whole instance now: `new HepPlanner(hepProgram, context.getContext)`. Calcite's `Context` is built in `TableEnvironment` now, and `VolcanoPlanner` and `HepPlanner` are built with this context instance. However they are built in difference places, `VolcanoPlanner` is built in `FlinkRelBuilder` and `HepPlanner` is built in `FlinkHepProgram`. What I'm worried about is someone may be forget to modify `FlinkHepProgram` when he/she wants to extend `Context` in `TableEnvironment`. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] godfreyhe commented on a change in pull request #7834: [FLINK-11715][table-planner-blink] Add optimize program to organize optimization phases
godfreyhe commented on a change in pull request #7834: [FLINK-11715][table-planner-blink] Add optimize program to organize optimization phases URL: https://github.com/apache/flink/pull/7834#discussion_r261170460 ## File path: flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/plan/optimize/program/OptimizeContext.scala ## @@ -0,0 +1,37 @@ +/* + * 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.optimize.program + +import org.apache.calcite.plan.{Context, RelOptPlanner} + +/** + * A OptimizeContext allows to obtain table environment information when optimizing. + */ +trait OptimizeContext { + + /** +* Gets the Calcite [[Context]] defined in [[org.apache.flink.table.api.TableEnvironment]]. +*/ + def getContext: Context Review comment: For most of program, they need not to know the content in the `Context`. The `Context` instance is only be used to create `HepPlanner` as a whole instance now: `new HepPlanner(hepProgram, context.getContext)`. Calcite's `Context` is built in `TableEnvironment` now, `VolcanoPlanner` and `HepPlanner` are built with this context instance, however they are built in difference place, `VolcanoPlanner` is built in `FlinkRelBuilder` and `HepPlanner` is built in `FlinkHepProgram`. Someone may be forget to modify `FlinkHepProgram` when he/she wants to extend `Context` in `TableEnvironment`. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] godfreyhe commented on a change in pull request #7834: [FLINK-11715][table-planner-blink] Add optimize program to organize optimization phases
godfreyhe commented on a change in pull request #7834: [FLINK-11715][table-planner-blink] Add optimize program to organize optimization phases URL: https://github.com/apache/flink/pull/7834#discussion_r261170460 ## File path: flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/plan/optimize/program/OptimizeContext.scala ## @@ -0,0 +1,37 @@ +/* + * 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.optimize.program + +import org.apache.calcite.plan.{Context, RelOptPlanner} + +/** + * A OptimizeContext allows to obtain table environment information when optimizing. + */ +trait OptimizeContext { + + /** +* Gets the Calcite [[Context]] defined in [[org.apache.flink.table.api.TableEnvironment]]. +*/ + def getContext: Context Review comment: For most of program, they need not to know the content in the `Context`. The `Context` instance is only be used to create `HepPlanner` now as a whole instance: `new HepPlanner(hepProgram, context.getContext)`. Calcite's `Context` is built in `TableEnvironment` now, `VolcanoPlanner` and `HepPlanner` are built with this context instance, however they are built in difference place, `VolcanoPlanner` is built in `FlinkRelBuilder` and `HepPlanner` is built in `FlinkHepProgram`. Someone may be forget to modify `FlinkHepProgram` when he/she wants to extend `Context` in `TableEnvironment`. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] godfreyhe commented on a change in pull request #7834: [FLINK-11715][table-planner-blink] Add optimize program to organize optimization phases
godfreyhe commented on a change in pull request #7834: [FLINK-11715][table-planner-blink] Add optimize program to organize optimization phases URL: https://github.com/apache/flink/pull/7834#discussion_r261139421 ## File path: flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/plan/optimize/program/FlinkChainedPrograms.scala ## @@ -0,0 +1,163 @@ +/* + * 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.optimize.program + +import org.apache.flink.table.api.TableException +import org.apache.flink.table.util.Logging +import org.apache.flink.util.Preconditions + +import org.apache.calcite.plan.RelOptUtil +import org.apache.calcite.rel.RelNode + +import java.util + +import scala.collection.JavaConversions._ + + +/** + * FlinkChainedPrograms contains a sequence of [[FlinkOptimizeProgram]]s which are chained + * together. + * + * The chained-order of programs can be adjusted by [[addFirst]], [[addLast]], [[addBefore]] + * and [[remove]] methods. + * + * When [[optimize]] method called, each program's optimize method will be called in sequence. + * + * @tparam OC OptimizeContext + */ +class FlinkChainedPrograms[OC <: OptimizeContext] extends Logging { Review comment: That's a good idea! This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] godfreyhe commented on a change in pull request #7834: [FLINK-11715][table-planner-blink] Add optimize program to organize optimization phases
godfreyhe commented on a change in pull request #7834: [FLINK-11715][table-planner-blink] Add optimize program to organize optimization phases URL: https://github.com/apache/flink/pull/7834#discussion_r261138389 ## File path: flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/plan/optimize/program/OptimizeContext.scala ## @@ -0,0 +1,37 @@ +/* + * 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.optimize.program + +import org.apache.calcite.plan.{Context, RelOptPlanner} + +/** + * A OptimizeContext allows to obtain table environment information when optimizing. + */ +trait OptimizeContext { + + /** +* Gets the Calcite [[Context]] defined in [[org.apache.flink.table.api.TableEnvironment]]. +*/ + def getContext: Context Review comment: Only `TableConfig` is not enough, `FunctionCatalog` is also needed by `RexNodeExtractor` which is used in `PushFilterIntoTableSourceScanRule` and `SelectivityEstimator` in Blink. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services