flyrain commented on code in PR #16131:
URL: https://github.com/apache/iceberg/pull/16131#discussion_r3770965111


##########
data/src/main/java/org/apache/iceberg/data/IcebergGenerics.java:
##########
@@ -103,7 +108,16 @@ public ScanBuilder metricsReporter(MetricsReporter 
reporter) {
     }
 
     public CloseableIterable<Record> build() {
-      return new TableScanIterable(tableScan, reuseContainers);
+      Optional<ReadRestrictions> restrictions = 
TableUtil.readRestrictions(table);
+      if (restrictions.isPresent() && restrictions.get().rowFilter() != null) {
+        this.tableScan = tableScan.filter(restrictions.get().rowFilter());
+      }
+
+      CloseableIterable<Record> records = new TableScanIterable(tableScan, 
reuseContainers);
+      if (restrictions.isPresent()) {
+        records = ReadRestrictionsApplier.apply(records, restrictions.get(), 
tableScan.schema());

Review Comment:
   [P2] `TableScanIterable` has already called `scan.planTasks()` before 
restriction binding happens here. If `ReadRestrictionsApplier.apply` throws 
while binding an unknown/unsupported/nested action or row filter, the planned 
task iterable is never closed. Please bind before constructing the iterable, or 
close `records` in an exception path before rethrowing.



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