szlta commented on a change in pull request #3248:
URL: https://github.com/apache/iceberg/pull/3248#discussion_r726040970
##########
File path: spark/src/main/java/org/apache/iceberg/spark/data/SparkOrcWriter.java
##########
@@ -42,75 +46,72 @@
*/
public class SparkOrcWriter implements OrcRowWriter<InternalRow> {
- private final SparkOrcValueWriter writer;
+ private final InternalRowWriter writer;
public SparkOrcWriter(Schema iSchema, TypeDescription orcSchema) {
Preconditions.checkArgument(orcSchema.getCategory() ==
TypeDescription.Category.STRUCT,
"Top level must be a struct " + orcSchema);
- writer = OrcSchemaWithTypeVisitor.visit(iSchema, orcSchema, new
WriteBuilder());
+ writer = (InternalRowWriter) OrcSchemaWithTypeVisitor.visit(iSchema,
orcSchema, new WriteBuilder());
}
@Override
public void write(InternalRow value, VectorizedRowBatch output) {
- Preconditions.checkArgument(writer instanceof StructWriter, "writer must
be StructWriter");
+ Preconditions.checkArgument(value != null, "value must not be null");
Review comment:
The variable "value" cannot be null in the original version either. If
it was null, it would get passed here:
https://github.com/apache/iceberg/blob/master/spark/src/main/java/org/apache/iceberg/spark/data/SparkOrcWriter.java#L63
..and would throw an NPE here:
https://github.com/apache/iceberg/blob/master/spark/src/main/java/org/apache/iceberg/spark/data/SparkOrcValueWriter.java#L38
After my change we just throw a nicer exception for the same situation.
--
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]