bryanck commented on code in PR #18148:
URL: https://github.com/apache/iceberg/pull/18148#discussion_r4166380548
##########
spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/source/SparkChangelogScanBuilder.java:
##########
@@ -35,11 +43,45 @@
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> changelogPredicates = Lists.newArrayList();
+ List<Predicate> pushable = Lists.newArrayList();
+
+ for (Predicate predicate : predicates) {
+ if (isChangelogColumnPredicate(predicate)) {
+ changelogPredicates.add(predicate);
+ } else {
+ pushable.add(predicate);
+ }
+ }
+
+ Predicate[] remainingPredicates =
super.pushPredicates(pushable.toArray(new Predicate[0]));
+
+ return Stream.concat(Arrays.stream(remainingPredicates),
changelogPredicates.stream())
+ .toArray(Predicate[]::new);
Review Comment:
I feel this could be simplified a little to avoid the Stream import. You
could rename `changelogPredicates` to `postScanPredicates` or similar, and then
append `remainingPredicates` to that, what do you think? e.g.
```
postScanPredicates.addAll(Arrays.asList(remainingPredicates));
return postScanPredicates.toArray(Predicate[]::new);
```
--
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]