wenlong88 commented on a change in pull request #15062:
URL: https://github.com/apache/flink/pull/15062#discussion_r586163272
##########
File path:
flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/plan/utils/RexNodeExtractor.scala
##########
@@ -108,18 +130,15 @@ object RexNodeExtractor extends Logging {
// converts the cnf condition to a list of AND conditions
val conjunctions = RelOptUtil.conjunctions(cnf)
- val convertedExpressions = new mutable.ArrayBuffer[Expression]
+ val convertibleRexNodes = new mutable.ArrayBuffer[RexNode]
val unconvertedRexNodes = new mutable.ArrayBuffer[RexNode]
- val inputNames = inputFieldNames.asScala.toArray
- val converter = new RexNodeToExpressionConverter(
- rexBuilder, inputNames, functionCatalog, catalogManager, timeZone)
conjunctions.asScala.foreach(rex => {
rex.accept(converter) match {
- case Some(expression) => convertedExpressions += expression
Review comment:
there is a regression here: for rexnode which can not be converted to a
expression, will be treated as convertible rexnode
##########
File path:
flink-table/flink-table-planner-blink/src/main/java/org/apache/flink/table/planner/plan/abilities/source/FilterPushDownSpec.java
##########
@@ -0,0 +1,105 @@
+/*
+ * 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.abilities.source;
+
+import org.apache.flink.table.api.TableException;
+import org.apache.flink.table.connector.source.DynamicTableSource;
+import
org.apache.flink.table.connector.source.abilities.SupportsFilterPushDown;
+import org.apache.flink.table.expressions.Expression;
+import org.apache.flink.table.expressions.resolver.ExpressionResolver;
+import org.apache.flink.table.planner.calcite.FlinkTypeFactory;
+import org.apache.flink.table.planner.plan.utils.RexNodeToExpressionConverter;
+
+import
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonCreator;
+import
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonProperty;
+import
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonTypeName;
+
+import org.apache.calcite.rex.RexBuilder;
+import org.apache.calcite.rex.RexNode;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import java.util.TimeZone;
+import java.util.stream.Collectors;
+
+import static org.apache.flink.util.Preconditions.checkNotNull;
+
+/**
+ * A sub-class of {@link SourceAbilitySpec} that can not only
serialize/deserialize the filter
+ * to/from JSON, but also can push the filter into a {@link
SupportsFilterPushDown}.
+ */
+@JsonTypeName("FilterPushDown")
+public class FilterPushDownSpec implements SourceAbilitySpec {
+ public static final String FIELD_NAME_PREDICATES = "predicates";
+
+ @JsonProperty(FIELD_NAME_PREDICATES)
+ private final List<RexNode> predicates;
+
+ @JsonCreator
+ public FilterPushDownSpec(@JsonProperty(FIELD_NAME_PREDICATES)
List<RexNode> predicates) {
+ this.predicates = new ArrayList<>(checkNotNull(predicates));
+ }
+
+ @Override
+ public void apply(DynamicTableSource tableSource, SourceAbilityContext
context) {
+ apply(predicates, tableSource, context);
Review comment:
I think we need to check that t all predicates is accepted by the source
after deserialization
----------------------------------------------------------------
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]