wypoon commented on code in PR #4588:
URL: https://github.com/apache/iceberg/pull/4588#discussion_r853347186
##########
spark/v3.2/spark/src/main/java/org/apache/iceberg/spark/data/vectorized/ColumnVectorWithFilter.java:
##########
@@ -97,9 +97,18 @@ public byte[] getBinary(int rowId) {
return accessor().getBinary(rowIdMapping[rowId]);
}
+ static ConstantColumnVector constantColumnVector(VectorHolder holder, int
numRows) {
+ Object constant = ((ConstantVectorHolder) holder).getConstant();
+ if (constant instanceof Boolean) {
+ return new ConstantColumnVector(Types.BooleanType.get(), numRows,
constant);
+ } else {
+ return new ConstantColumnVector(Types.IntegerType.get(), numRows,
constant);
+ }
+ }
+
public static ColumnVector forHolder(VectorHolder holder, int[]
rowIdMapping, int numRows) {
return holder.isDummy() ?
- new ConstantColumnVector(Types.IntegerType.get(), numRows,
((ConstantVectorHolder) holder).getConstant()) :
Review Comment:
I do not know why the `ConstantColumnVector` is constructed with a hardcoded
integer type. I observe that this code here can get called with
`ConstantVectorHolder`s containing a constant of other primitive types. If
`copy()` is called on an `InternalRow` in the `ColumnarBatch` containing this
`ColumnVector`, then we get a `ClassCastException`. In the situations where I
call `copy()`, the `ConstantColumnVector` contains either a boolean or an
integer, so I only fix it for those possibilities.
--
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]