rdblue commented on a change in pull request #3722:
URL: https://github.com/apache/iceberg/pull/3722#discussion_r770147913
##########
File path:
spark/v3.2/spark/src/main/java/org/apache/iceberg/spark/source/SparkTable.java
##########
@@ -286,4 +299,20 @@ public int hashCode() {
// use only name in order to correctly invalidate Spark cache
return icebergTable.name().hashCode();
}
+
+ private static CaseInsensitiveStringMap
addSnapshotId(CaseInsensitiveStringMap options, Long snapshotId) {
+ if (snapshotId != null) {
+ String snapshotIdFromOptions = options.get(SparkReadOptions.SNAPSHOT_ID);
+ Preconditions.checkArgument(snapshotIdFromOptions == null,
+ "Cannot override snapshot ID more than once: %s",
snapshotIdFromOptions);
+
+ Map<String, String> scanOptions = Maps.newHashMap();
+ scanOptions.putAll(options.asCaseSensitiveMap());
+ scanOptions.put(SparkReadOptions.SNAPSHOT_ID,
String.valueOf(snapshotId));
Review comment:
I updated this to the following and tests work fine:
```java
private static CaseInsensitiveStringMap
addSnapshotId(CaseInsensitiveStringMap options, Long snapshotId) {
if (snapshotId != null) {
String snapshotIdFromOptions =
options.get(SparkReadOptions.SNAPSHOT_ID);
Preconditions.checkArgument(snapshotIdFromOptions == null ||
snapshotId.toString().equals(snapshotIdFromOptions),
"Cannot override snapshot ID more than once: %s",
snapshotIdFromOptions);
Map<String, String> scanOptions = Maps.newHashMap();
scanOptions.putAll(options.asCaseSensitiveMap());
scanOptions.put(SparkReadOptions.SNAPSHOT_ID,
String.valueOf(snapshotId));
scanOptions.remove(SparkReadOptions.AS_OF_TIMESTAMP);
return new CaseInsensitiveStringMap(scanOptions);
}
return options;
}
```
--
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]