jtuglu1 commented on code in PR #18953:
URL: https://github.com/apache/druid/pull/18953#discussion_r2734703265


##########
extensions-contrib/druid-iceberg-extensions/src/main/java/org/apache/druid/iceberg/input/IcebergCatalog.java:
##########
@@ -100,12 +127,47 @@ public List<String> extractSnapshotDataFiles(
 
       tableScan = tableScan.caseSensitive(isCaseSensitive());
       CloseableIterable<FileScanTask> tasks = tableScan.planFiles();
-      CloseableIterable.transform(tasks, FileScanTask::file)
-                       .forEach(dataFile -> 
dataFilePaths.add(dataFile.path().toString()));
+
+      Expression detectedResidual = null;
+      for (FileScanTask task : tasks) {
+        dataFilePaths.add(task.file().path().toString());
+
+        // Check for residual filters if mode is not IGNORE
+        if (effectiveMode != ResidualFilterMode.IGNORE && detectedResidual == 
null) {
+          Expression residual = task.residual();
+          if (residual != null && !residual.equals(Expressions.alwaysTrue())) {
+            detectedResidual = residual;
+          }
+        }
+      }
+
+      // Handle residual filter based on mode
+      if (detectedResidual != null) {
+        String message = StringUtils.format(
+            "Iceberg filter produced residual expression that requires 
row-level filtering. "
+            + "This typically means the filter is on a non-partition column. "
+            + "Residual rows may be ingested unless filtered by transformSpec. 
"
+            + "Residual filter: [%s]",
+            detectedResidual
+        );
+
+        if (effectiveMode == ResidualFilterMode.FAIL) {
+          throw new IAE(
+              "%s To allow residual rows, set residualFilterMode to 'ignore' 
or 'warn', "
+              + "or add a corresponding filter in transformSpec.",
+              message
+          );
+        } else if (effectiveMode == ResidualFilterMode.WARN) {
+          log.warn(message);
+        }
+      }

Review Comment:
   That's fine with me. It's only a single log and reduces branching.



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