lliangyu-lin commented on code in PR #11967:
URL: https://github.com/apache/iceberg/pull/11967#discussion_r1917821160


##########
spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/source/SparkScanBuilder.java:
##########
@@ -561,14 +561,11 @@ public Scan buildChangelogScan() {
 
     boolean emptyScan = false;
     if (startTimestamp != null) {
-      if (table.currentSnapshot() != null
-          && table.currentSnapshot().timestampMillis() < startTimestamp) {
+      if (table.currentSnapshot() == null
+          || startTimestamp > table.currentSnapshot().timestampMillis()) {
         emptyScan = true;
       }
       startSnapshotId = getStartSnapshotId(startTimestamp);
-      if (startSnapshotId == null && endTimestamp == null) {
-        emptyScan = true;
-      }
     }
 
     if (endTimestamp != null) {

Review Comment:
   > Should we consider moving the following part out of the if (endTimestamp 
!= null) {} block?
   
   I think directly moving out this code block will cause issues because now if 
user do not specify any read options, like in ```testUpdate```, it will always 
flag to be empty scan.
   
   > One scenario that might cause this is when:
   > 
   > startSnapshotId is null
   > endTimestamp is null
   > endSnapshotId is null
   
   The first assert in ```testOnlyStartTimestampInput``` address this scenario. 
   
   When startSnapShotId resolves to null, which means either user specified to 
scan from root snapshot, or given startTimestamp and can only finds 
startSnapshotId to be null (rootSnapShot), otherwise ```startTimestamp > 
table.currentSnapshot().timestampMillis()``` already flags to be empty scan. 
Then both endTimestamp and endSnapshotId be null just means we will scan till 
the current snapshot.



-- 
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-unsubscr...@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to