slessard commented on code in PR #10953:
URL: https://github.com/apache/iceberg/pull/10953#discussion_r1773673837
##########
arrow/src/main/java/org/apache/iceberg/arrow/vectorized/VectorHolder.java:
##########
@@ -140,12 +141,18 @@ public static class ConstantVectorHolder<T> extends
VectorHolder {
private final int numRows;
public ConstantVectorHolder(int numRows) {
+ super(new NullVector("_dummy_", numRows), null, new
NullabilityHolder(numRows));
+ nullabilityHolder().setNulls(0, numRows);
this.numRows = numRows;
this.constantValue = null;
}
public ConstantVectorHolder(Types.NestedField icebergField, int numRows, T
constantValue) {
- super(icebergField);
+ super(
+ new NullVector(icebergField.name(), numRows),
Review Comment:
@nastra, @amogh-jahagirdar This change causes the Spark tests the fail.
I've analyzed the failure and concluded that this change, as is, assumes that
ConstantVectorHolder will only ever hold a null value. The below patch fixes
the issue, but it feels like a bit of a hack to me. I dislike the ternary
operator in the call to `super` that checks whether `constantValue` is null
followed by a second check of the same condition before the call to
`nullabilityHolder().setNulls(0, numRows);`. What do you think?
```
Subject: [PATCH] Changes
---
Index:
arrow/src/main/java/org/apache/iceberg/arrow/vectorized/VectorHolder.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git
a/arrow/src/main/java/org/apache/iceberg/arrow/vectorized/VectorHolder.java
b/arrow/src/main/java/org/apache/iceberg/arrow/vectorized/VectorHolder.java
---
a/arrow/src/main/java/org/apache/iceberg/arrow/vectorized/VectorHolder.java
(revision 1a3896bba82e1e92142b237e1cd9332d67171b19)
+++
b/arrow/src/main/java/org/apache/iceberg/arrow/vectorized/VectorHolder.java
(date 1727193972380)
@@ -149,10 +149,12 @@
public ConstantVectorHolder(Types.NestedField icebergField, int
numRows, T constantValue) {
super(
- new NullVector(icebergField.name(), numRows),
+ (null == constantValue) ? new NullVector(icebergField.name(),
numRows) : null,
icebergField,
new NullabilityHolder(numRows));
- nullabilityHolder().setNulls(0, numRows);
+ if (null == constantValue) {
+ nullabilityHolder().setNulls(0, numRows);
+ }
this.numRows = numRows;
this.constantValue = constantValue;
}
```
--
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]