Copilot commented on code in PR #9286:
URL: https://github.com/apache/gravitino/pull/9286#discussion_r2570220089
##########
iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/TestIcebergTableOperations.java:
##########
@@ -233,25 +214,11 @@ void
testPlanTableScanWithIncrementalAppendScanValidRange(Namespace namespace) {
Assertions.assertNotNull(snapshots, "Snapshots should not be null");
Assertions.assertTrue(snapshots.size() >= 2, "Should have at least 2
snapshots");
- // Sort by sequence number to get ordered snapshots
- List<Snapshot> sortedSnapshots =
- snapshots.stream()
- .sorted((s1, s2) -> Long.compare(s1.snapshotId(), s2.snapshotId()))
- .collect(java.util.stream.Collectors.toList());
-
- Assertions.assertTrue(
- sortedSnapshots.size() >= 2,
- "Should have at least 2 snapshots for incremental scan test, but got: "
- + sortedSnapshots.size());
-
- // For IncrementalAppendScan, start snapshot must be an ancestor of end
snapshot
- // Use the last snapshot as end, and find its parent from the sorted list
- Snapshot endSnapshot = sortedSnapshots.get(sortedSnapshots.size() - 1);
+ Snapshot endSnapshot = snapshots.get(snapshots.size() - 1);
Long endSnapshotId = endSnapshot.snapshotId();
- Long startSnapshotId = endSnapshot.parentId();
+ Snapshot startSnapshot = snapshots.get(snapshots.size() - 2);
+ Long startSnapshotId = startSnapshot.snapshotId();
Review Comment:
The test assumes that the last two snapshots in the list have an ancestor
relationship required by `IncrementalAppendScan`, but this is not guaranteed.
The `metadata.snapshots()` list order may not reflect the parent-child
relationships in the snapshot tree. Consider using `endSnapshot.parentId()` to
get a valid ancestor snapshot, or use `table.history()` to get chronologically
ordered snapshots with proper lineage.
```suggestion
Long startSnapshotId = endSnapshot.parentId();
Assertions.assertNotNull(startSnapshotId, "End snapshot should have a
parent snapshot for incremental scan");
```
##########
iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/CatalogWrapperForREST.java:
##########
@@ -365,7 +359,7 @@ private CloseableIterable<FileScanTask>
createFilePlanScanTasks(
return incrementalScan.planFiles();
} else {
TableScan tableScan = table.newScan();
- if (scanRequest.snapshotId() != null && scanRequest.snapshotId() != 0L) {
+ if (scanRequest.snapshotId() != null) {
Review Comment:
Removing the `!= 0L` check changes the behavior when `snapshotId` is
explicitly set to `0L`. Previously, `0L` was treated as 'no snapshot
specified', but now it will be passed to `useSnapshot(0L)` which may cause
errors since 0 is not a valid snapshot ID. Consider restoring the `&&
scanRequest.snapshotId() != 0L` check or document this as a breaking change if
intentional.
```suggestion
if (scanRequest.snapshotId() != null && scanRequest.snapshotId() !=
0L) {
```
--
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]