szehon-ho commented on code in PR #7120:
URL: https://github.com/apache/iceberg/pull/7120#discussion_r1163389284
##########
spark/v3.1/spark/src/main/java/org/apache/iceberg/spark/source/SparkWrite.java:
##########
@@ -127,6 +129,15 @@ class SparkWrite {
this.dsSchema = dsSchema;
this.extraSnapshotMetadata = writeConf.extraSnapshotMetadata();
this.partitionedFanoutEnabled = writeConf.fanoutWriterEnabled();
+
+ Preconditions.checkArgument(
+ writeConf.outputSpecId() == null ||
table.specs().containsKey(writeConf.outputSpecId()),
+ "Cannot write to unknown spec: %s",
+ writeConf.outputSpecId());
+ this.outputSpecId =
+ writeConf.outputSpecId() != null
+ ? table.specs().get(writeConf.outputSpecId()).specId()
Review Comment:
I think this is a bit redundant, but if we go with previous suggestion it
will be not necessary?
##########
spark/v3.1/spark/src/main/java/org/apache/iceberg/spark/source/SparkWrite.java:
##########
@@ -127,6 +129,15 @@ class SparkWrite {
this.dsSchema = dsSchema;
this.extraSnapshotMetadata = writeConf.extraSnapshotMetadata();
this.partitionedFanoutEnabled = writeConf.fanoutWriterEnabled();
+
+ Preconditions.checkArgument(
Review Comment:
Nit: This is a bit hard to read, would this be better?
```
if (writeConf.outputSpecId == null) {
this.outputSpecId = table.spec().specId();
} else {
this.outputSpecId = writeConf.outputSpecId();
Preconditions.checkArgument(table.specs().containsKey(outputSpecId), ...);
}
```
--
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]