fsk119 commented on a change in pull request #15307:
URL: https://github.com/apache/flink/pull/15307#discussion_r607091494



##########
File path: 
flink-table/flink-table-planner-blink/src/test/java/org/apache/flink/table/planner/plan/rules/logical/PushFilterInCalcIntoTableSourceRuleTest.java
##########
@@ -0,0 +1,137 @@
+/*
+ * 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.plan.rules.logical;
+
+import org.apache.flink.table.api.TableConfig;
+import org.apache.flink.table.planner.plan.nodes.FlinkConventions;
+import org.apache.flink.table.planner.plan.nodes.logical.FlinkLogicalCalc;
+import 
org.apache.flink.table.planner.plan.nodes.logical.FlinkLogicalTableSourceScan;
+import 
org.apache.flink.table.planner.plan.nodes.logical.FlinkLogicalWatermarkAssigner;
+import 
org.apache.flink.table.planner.plan.optimize.program.FlinkChainedProgram;
+import 
org.apache.flink.table.planner.plan.optimize.program.FlinkHepRuleSetProgramBuilder;
+import 
org.apache.flink.table.planner.plan.optimize.program.FlinkVolcanoProgramBuilder;
+import 
org.apache.flink.table.planner.plan.optimize.program.HEP_RULES_EXECUTION_TYPE;
+import 
org.apache.flink.table.planner.plan.optimize.program.StreamOptimizeContext;
+import org.apache.flink.table.planner.utils.StreamTableTestUtil;
+import org.apache.flink.table.planner.utils.TableTestBase;
+
+import org.apache.calcite.plan.Convention;
+import org.apache.calcite.plan.hep.HepMatchOrder;
+import org.apache.calcite.rel.rules.CoreRules;
+import org.apache.calcite.tools.RuleSets;
+import org.junit.Before;
+import org.junit.Test;
+
+/** Test for {@link PushFilterInCalcIntoTableSourceRuleTest}. */
+public class PushFilterInCalcIntoTableSourceRuleTest extends TableTestBase {
+
+    private final StreamTableTestUtil util = streamTestUtil(new TableConfig());
+
+    @Before
+    public void setup() {
+        FlinkChainedProgram<StreamOptimizeContext> program = new 
FlinkChainedProgram<>();
+        program.addLast(
+                "Converters",
+                FlinkVolcanoProgramBuilder.<StreamOptimizeContext>newBuilder()
+                        .add(
+                                RuleSets.ofList(
+                                        CoreRules.PROJECT_TO_CALC,
+                                        CoreRules.FILTER_TO_CALC,
+                                        FlinkLogicalCalc.CONVERTER(),
+                                        
FlinkLogicalTableSourceScan.CONVERTER(),
+                                        
FlinkLogicalWatermarkAssigner.CONVERTER()))
+                        .setRequiredOutputTraits(new Convention[] 
{FlinkConventions.LOGICAL()})
+                        .build());
+        program.addLast(
+                "PushWatermarkIntoTableSourceScanRule",
+                
FlinkHepRuleSetProgramBuilder.<StreamOptimizeContext>newBuilder()
+                        
.setHepRulesExecutionType(HEP_RULES_EXECUTION_TYPE.RULE_SEQUENCE())
+                        .setHepMatchOrder(HepMatchOrder.BOTTOM_UP)
+                        .add(
+                                RuleSets.ofList(
+                                        
PushWatermarkIntoTableSourceScanRule.INSTANCE,
+                                        
PushWatermarkIntoTableSourceScanAcrossCalcRule.INSTANCE))
+                        .build());
+        program.addLast(
+                "Filter push down",
+                
FlinkHepRuleSetProgramBuilder.<StreamOptimizeContext>newBuilder()
+                        
.setHepRulesExecutionType(HEP_RULES_EXECUTION_TYPE.RULE_SEQUENCE())
+                        .setHepMatchOrder(HepMatchOrder.BOTTOM_UP)
+                        
.add(RuleSets.ofList(PushFilterIntoTableSourceScanRule.INSTANCE, 
PushFilterInCalcIntoTableSourceScanRule.INSTANCE))

Review comment:
       Remove `PushFilterIntoTableSourceScanRule.INSTANCE`.
   
   `PushFilterInCalcIntoTableSourceScanRule.INSTANCE` is enough.

##########
File path: 
flink-table/flink-table-planner-blink/src/test/java/org/apache/flink/table/planner/plan/rules/logical/PushFilterInCalcIntoTableSourceRuleTest.java
##########
@@ -0,0 +1,137 @@
+/*
+ * 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.plan.rules.logical;
+
+import org.apache.flink.table.api.TableConfig;
+import org.apache.flink.table.planner.plan.nodes.FlinkConventions;
+import org.apache.flink.table.planner.plan.nodes.logical.FlinkLogicalCalc;
+import 
org.apache.flink.table.planner.plan.nodes.logical.FlinkLogicalTableSourceScan;
+import 
org.apache.flink.table.planner.plan.nodes.logical.FlinkLogicalWatermarkAssigner;
+import 
org.apache.flink.table.planner.plan.optimize.program.FlinkChainedProgram;
+import 
org.apache.flink.table.planner.plan.optimize.program.FlinkHepRuleSetProgramBuilder;
+import 
org.apache.flink.table.planner.plan.optimize.program.FlinkVolcanoProgramBuilder;
+import 
org.apache.flink.table.planner.plan.optimize.program.HEP_RULES_EXECUTION_TYPE;
+import 
org.apache.flink.table.planner.plan.optimize.program.StreamOptimizeContext;
+import org.apache.flink.table.planner.utils.StreamTableTestUtil;
+import org.apache.flink.table.planner.utils.TableTestBase;
+
+import org.apache.calcite.plan.Convention;
+import org.apache.calcite.plan.hep.HepMatchOrder;
+import org.apache.calcite.rel.rules.CoreRules;
+import org.apache.calcite.tools.RuleSets;
+import org.junit.Before;
+import org.junit.Test;
+
+/** Test for {@link PushFilterInCalcIntoTableSourceRuleTest}. */
+public class PushFilterInCalcIntoTableSourceRuleTest extends TableTestBase {
+
+    private final StreamTableTestUtil util = streamTestUtil(new TableConfig());
+
+    @Before
+    public void setup() {
+        FlinkChainedProgram<StreamOptimizeContext> program = new 
FlinkChainedProgram<>();
+        program.addLast(
+                "Converters",
+                FlinkVolcanoProgramBuilder.<StreamOptimizeContext>newBuilder()
+                        .add(
+                                RuleSets.ofList(
+                                        CoreRules.PROJECT_TO_CALC,
+                                        CoreRules.FILTER_TO_CALC,
+                                        FlinkLogicalCalc.CONVERTER(),
+                                        
FlinkLogicalTableSourceScan.CONVERTER(),
+                                        
FlinkLogicalWatermarkAssigner.CONVERTER()))
+                        .setRequiredOutputTraits(new Convention[] 
{FlinkConventions.LOGICAL()})
+                        .build());
+        program.addLast(
+                "PushWatermarkIntoTableSourceScanRule",
+                
FlinkHepRuleSetProgramBuilder.<StreamOptimizeContext>newBuilder()
+                        
.setHepRulesExecutionType(HEP_RULES_EXECUTION_TYPE.RULE_SEQUENCE())
+                        .setHepMatchOrder(HepMatchOrder.BOTTOM_UP)
+                        .add(
+                                RuleSets.ofList(
+                                        
PushWatermarkIntoTableSourceScanRule.INSTANCE,
+                                        
PushWatermarkIntoTableSourceScanAcrossCalcRule.INSTANCE))
+                        .build());

Review comment:
       After carefully thinking, I think we should test the rule 
`PushFilterInCalcIntoTableSourceScanRule` only (don't introduce other unrelated 
rule, e.g `PushWatermarkIntoTableSourceScanRule`) and move the test about push 
filter after watermark push down to the `FilterableSourceTest`. Therefore, in 
the `PushFilterInCalcIntoTableSourceRuleTest`, we just need to add test 
about`FailToPushFilterIntoTableSourceWithoutWatermarkPushDown` and all the test 
in `PushFilterIntoTableSourceScanRuleTest`. After this, I think we can make the 
UT test as simple as possbile and we can pay attention to the rule itself.
   
   What do you think?
   




-- 
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:
us...@infra.apache.org


Reply via email to