You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@fluss.apache.org by "platinumhamburg (via GitHub)" <gi...@apache.org> on 2025/07/02 06:32:39 UTC

Re: [PR] [flink]Support partition pushdown in Flink connector [fluss]

platinumhamburg commented on code in PR #420:
URL: https://github.com/apache/fluss/pull/420#discussion_r2179221258


##########
fluss-flink/fluss-flink-common/src/main/java/com/alibaba/fluss/flink/source/FlinkTableSource.java:
##########
@@ -128,7 +133,7 @@ public class FlinkTableSource
 
     private long limit = -1;
 
-    private List<FieldEqual> partitionFilters = Collections.emptyList();
+    @Nullable protected Predicate predicate;

Review Comment:
   'predicate' should be renamed to 'partitionFilters', because more pushdowned filter types will be supported in the future.



##########
fluss-flink/fluss-flink-common/src/main/java/com/alibaba/fluss/flink/source/FlinkTableSource.java:
##########
@@ -419,23 +426,51 @@ && hasPrimaryKey()
             }
             singleRowFilter = lookupRow;
             return Result.of(acceptedFilters, remainingFilters);
-        } else if (isPartitioned()) {
-            // dynamic partition pushdown
-            List<FieldEqual> fieldEquals =
-                    extractFieldEquals(
-                            filters,
-                            getPartitionKeyTypes(),
-                            acceptedFilters,
-                            remainingFilters,
-                            FLINK_INTERNAL_VALUE);
-            // partitions are filtered by string representations, convert the equals to string first
-            fieldEquals = stringifyFieldEquals(fieldEquals);
-
-            this.partitionFilters = fieldEquals;
+        } else if (isPartitioned()
+                && !RowLevelModificationType.UPDATE.equals(modificationScanType)) {
+            // apply partition filter pushdown
+            List<Predicate> converted = new ArrayList<>();
+
+            List<String> fieldNames = tableOutputType.getFieldNames();
+            List<String> partitionKeys =
+                    Arrays.stream(partitionKeyIndexes)
+                            .mapToObj(fieldNames::get)
+                            .collect(Collectors.toList());
+
+            PredicateVisitor<Boolean> partitionPredicateVisitor =
+                    new PartitionPredicateVisitor(partitionKeys);
+
+            // TODO after https://github.com/alibaba/fluss/pull/979
+            //  replace string type with the real type
+            LogicalType[] partitionKeyTypes =
+                    partitionKeys.stream()
+                            .map(key -> VarCharType.STRING_TYPE)
+                            .toArray(LogicalType[]::new);
+            for (ResolvedExpression filter : filters) {
+
+                Optional<Predicate> predicateOptional =
+                        PredicateConverter.convert(
+                                org.apache.flink.table.types.logical.RowType.of(

Review Comment:
   The filter list may contain unexpected expressions that refer to non-partition key columns. Moreover, the row type passed to PredicateConverter only includes partition keys, which could lead to unexpected exceptions during conversion.



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@fluss.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org