manuzhang commented on code in PR #18148:
URL: https://github.com/apache/iceberg/pull/18148#discussion_r4089014975


##########
spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/source/SparkChangelogScanBuilder.java:
##########
@@ -35,11 +43,46 @@
 public class SparkChangelogScanBuilder extends BaseSparkScanBuilder
     implements SupportsPushDownV2Filters, SupportsPushDownRequiredColumns, 
SupportsPushDownLimit {
 
+  private static final Set<String> CHANGELOG_METADATA_COLUMNS =
+      ImmutableSet.of(
+          MetadataColumns.CHANGE_TYPE.name(),
+          MetadataColumns.CHANGE_ORDINAL.name(),
+          MetadataColumns.COMMIT_SNAPSHOT_ID.name());
+
   SparkChangelogScanBuilder(
       SparkSession spark, Table table, Schema schema, CaseInsensitiveStringMap 
options) {
     super(spark, table, schema, options);
   }
 
+  @Override
+  public Predicate[] pushPredicates(Predicate[] predicates) {
+    List<Predicate> unpushableChangelogPredicates = Lists.newArrayList();
+    List<Predicate> pushableCandidates = Lists.newArrayList();
+
+    for (Predicate predicate : predicates) {
+      if (isChangelogColumnPredicate(predicate)) {
+        unpushableChangelogPredicates.add(predicate);
+      } else {
+        pushableCandidates.add(predicate);
+      }
+    }
+
+    Predicate[] remainingPredicates =
+        super.pushPredicates(pushableCandidates.toArray(new Predicate[0]));
+
+    return Stream.concat(Arrays.stream(remainingPredicates), 
unpushableChangelogPredicates.stream())

Review Comment:
   why not just filter out `CHANGELOG_METADATA_COLUMNS`?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to