marton-bod commented on code in PR #3222:
URL: https://github.com/apache/hive/pull/3222#discussion_r853924951


##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/mapreduce/IcebergInputFormat.java:
##########
@@ -207,6 +218,39 @@ public RecordReader<Void, T> createRecordReader(InputSplit 
split, TaskAttemptCon
     return new IcebergRecordReader<>();
   }
 
+  private static TableScan scanWithTimeRange(Table table, Configuration conf, 
TableScan scan, long fromTime) {
+    // let's find the corresponding snapshot ID - if the fromTime is before 
the table creation happened, let's use
+    // the first snapshot of the table
+    long fromSnapshot = IcebergTableUtil.findSnapshotForTimestamp(table, 
fromTime)
+        .orElseGet(() -> table.history().get(0).snapshotId());
+    if (fromSnapshot == table.currentSnapshot().snapshotId()) {
+      throw new IllegalArgumentException(
+          "Provided FROM timestamp must be earlier than the latest snapshot of 
the table.");
+    }
+    long toTime = conf.getLong(InputFormatConfig.TO_TIMESTAMP, -1);
+    if (toTime != -1) {
+      if (fromTime >= toTime) {
+        throw new IllegalArgumentException(
+            "Provided FROM timestamp must precede the provided TO timestamp.");
+      }
+      long toSnapshot = IcebergTableUtil.findSnapshotForTimestamp(table, 
toTime)
+          .orElseThrow(() -> new IllegalArgumentException(
+              "Provided TO timestamp must be after the first snapshot of the 
table."));
+      return scan.appendsBetween(fromSnapshot, toSnapshot);
+    } else {
+      return scan.appendsAfter(fromSnapshot);
+    }
+  }
+
+  private static TableScan scanWithVersionRange(Configuration conf, TableScan 
scan, long fromSnapshot) {
+    long toSnapshot = conf.getLong(InputFormatConfig.TO_VERSION, -1);

Review Comment:
   Sure



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