Github user ppadma commented on a diff in the pull request: https://github.com/apache/drill/pull/1107#discussion_r167380394 --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/spill/RecordBatchSizer.java --- @@ -137,10 +137,10 @@ public ColumnSize(ValueVector v, String prefix) { case MAP: case UNION: // No standard size for Union type - dataSize = v.getPayloadByteCount(valueCount); + dataSize = valueCount == 0 ? 0 : v.getPayloadByteCount(valueCount); --- End diff -- When we get empty batch, getPayloadByteCount will throw out of bounds exception if the underlying method tries to read the value vector for index 0 i.e. when it is trying to read offset vector. I added the check in those methods and removed here. I still have to retain the check here for the case when we are trying to read the offset vector.
---