aokolnychyi commented on code in PR #8163:
URL: https://github.com/apache/iceberg/pull/8163#discussion_r1287824227
##########
spark/v3.4/spark/src/main/java/org/apache/iceberg/spark/procedures/SetCurrentSnapshotProcedure.java:
##########
@@ -78,17 +83,21 @@ public StructType outputType() {
@Override
public InternalRow[] call(InternalRow args) {
Identifier tableIdent = toIdentifier(args.getString(0),
PARAMETERS[0].name());
- long snapshotId = args.getLong(1);
+ Long snapshotId = args.isNullAt(1) ? null : args.getLong(1);
+ String ref = args.isNullAt(2) ? null : args.getString(2);
+ Preconditions.checkArgument(
+ snapshotId != null || ref != null, "snapshot_id and ref cannot both be
null");
return modifyIcebergTable(
tableIdent,
table -> {
Snapshot previousSnapshot = table.currentSnapshot();
Long previousSnapshotId = previousSnapshot != null ?
previousSnapshot.snapshotId() : null;
- table.manageSnapshots().setCurrentSnapshot(snapshotId).commit();
+ long sid = snapshotId != null ? snapshotId :
getSnapshotIdFromRef(table, ref);
Review Comment:
Minor: We rarely use `get` in method names. What about `toSnapshotId`?
I'd also also rename `sid` into `targetSnapshotId` or something.
```
long targetSnapshotId = snapshotId != null ? snapshotId :
toSnapshotId(table, ref);
table.manageSnapshots().setCurrentSnapshot(targetSnapshotId).commit();
```
--
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]