NestDream opened a new pull request, #9944: URL: https://github.com/apache/paimon/pull/9944
### Purpose `CALL sys.rollback_to(`table` => 'default.T')` in Flink SQL, with neither `snapshot_id` nor `tag`, fails with `TableException: The call method caused an error: Cannot invoke "java.lang.Long.longValue()" because "snapshotId" is null`. The root cause is a bare `NullPointerException` from `table.rollbackTo(snapshotId)` auto-unboxing the null `Long`. On JDK 11 the NPE carries no message at all, so the user only sees `The call method caused an error: null.` Nothing tells them which argument is missing. The other direction is worse. `CALL sys.rollback_to(`table` => 'default.T', tag => 'tag-1', snapshot_id => 2)` succeeds, rolls back to the tag and ignores `snapshot_id`. The procedure returns `(3, 1)` and the table is at snapshot 1, although the user asked for snapshot 2. The Spark `RollbackProcedure` rejects both calls with `only can set one of version/snapshot/tag in RollbackProcedure.`, and the Flink `rollback_to_as_latest` procedure in the same package checks `hasTag != hasSnapshot` with `Must specify exactly one of tag and snapshot_id.`. This PR adds the same check with the same message to `rollback_to`, and fixes the argument names in `docs/docs/flink/procedures/snapshots.md` (the bullets said `snapshotId` and `tagName`, the named arguments are `snapshot_id` and `tag`) with one sentence that exactly one of them must be set. `rollback_to_timestamp` and `rollback_to_watermark` are not affected, their single argument is required. The Flink 1.18 copy of `rollback_to` uses positional overloads with a primitive `long` and is not affected either. ### Tests New `RollbackProcedureITCase#testRollbackToRequiresExactlyOneOfTagAndSnapshotId`: both invalid calls raise `IllegalArgumentException: Must specify exactly one of tag and snapshot_id.` and the table stays at snapshot 3. Without the fix the first call fails the test with the `NullPointerException` above and the second call rolls the table back. New `testRollbackToTreatsBlankTagAsMissing`: a whitespace-only `tag` alone and explicit `NULL` for both arguments are rejected the same way, and an empty `tag` next to a `snapshot_id` still rolls back to the snapshot, as before. The existing `testRollbackTo` and `RollbackToActionITCase` still pass. I also ran the four calls (neither, both, snapshot_id only, tag only) through a batch `TableEnvironment` on a local MiniCluster with a filesystem catalog against the unmodified module jar and the fixed one. Unmodified: the NPE above for "neither", silent rollback to the tag for "both". Fixed: the argument error for both, tables untouched. The two valid calls return `(3, 2)` and `(3, 1)` in both cases. -- 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]
