@@ -221,15 +221,21 @@ private void decodeDictionaryIds(int rowId, int num, ColumnVector column,
221221 if (column .dataType () == DataTypes .IntegerType ||
222222 DecimalType .is32BitDecimalType (column .dataType ())) {
223223 for (int i = rowId ; i < rowId + num ; ++i ) {
224- column .putInt (i , dictionary .decodeToInt (dictionaryIds .getDictId (i )));
224+ if (!column .isNullAt (i )) {
225+ column .putInt (i , dictionary .decodeToInt (dictionaryIds .getDictId (i )));
226+ }
225227 }
226228 } else if (column .dataType () == DataTypes .ByteType ) {
227229 for (int i = rowId ; i < rowId + num ; ++i ) {
228- column .putByte (i , (byte ) dictionary .decodeToInt (dictionaryIds .getDictId (i )));
230+ if (!column .isNullAt (i )) {
231+ column .putByte (i , (byte ) dictionary .decodeToInt (dictionaryIds .getDictId (i )));
232+ }
229233 }
230234 } else if (column .dataType () == DataTypes .ShortType ) {
231235 for (int i = rowId ; i < rowId + num ; ++i ) {
232- column .putShort (i , (short ) dictionary .decodeToInt (dictionaryIds .getDictId (i )));
236+ if (!column .isNullAt (i )) {
237+ column .putShort (i , (short ) dictionary .decodeToInt (dictionaryIds .getDictId (i )));
238+ }
233239 }
234240 } else {
235241 throw new UnsupportedOperationException ("Unimplemented type: " + column .dataType ());
@@ -240,7 +246,9 @@ private void decodeDictionaryIds(int rowId, int num, ColumnVector column,
240246 if (column .dataType () == DataTypes .LongType ||
241247 DecimalType .is64BitDecimalType (column .dataType ())) {
242248 for (int i = rowId ; i < rowId + num ; ++i ) {
243- column .putLong (i , dictionary .decodeToLong (dictionaryIds .getDictId (i )));
249+ if (!column .isNullAt (i )) {
250+ column .putLong (i , dictionary .decodeToLong (dictionaryIds .getDictId (i )));
251+ }
244252 }
245253 } else {
246254 throw new UnsupportedOperationException ("Unimplemented type: " + column .dataType ());
@@ -249,21 +257,27 @@ private void decodeDictionaryIds(int rowId, int num, ColumnVector column,
249257
250258 case FLOAT :
251259 for (int i = rowId ; i < rowId + num ; ++i ) {
252- column .putFloat (i , dictionary .decodeToFloat (dictionaryIds .getDictId (i )));
260+ if (!column .isNullAt (i )) {
261+ column .putFloat (i , dictionary .decodeToFloat (dictionaryIds .getDictId (i )));
262+ }
253263 }
254264 break ;
255265
256266 case DOUBLE :
257267 for (int i = rowId ; i < rowId + num ; ++i ) {
258- column .putDouble (i , dictionary .decodeToDouble (dictionaryIds .getDictId (i )));
268+ if (!column .isNullAt (i )) {
269+ column .putDouble (i , dictionary .decodeToDouble (dictionaryIds .getDictId (i )));
270+ }
259271 }
260272 break ;
261273 case INT96 :
262274 if (column .dataType () == DataTypes .TimestampType ) {
263275 for (int i = rowId ; i < rowId + num ; ++i ) {
264276 // TODO: Convert dictionary of Binaries to dictionary of Longs
265- Binary v = dictionary .decodeToBinary (dictionaryIds .getDictId (i ));
266- column .putLong (i , ParquetRowConverter .binaryToSQLTimestamp (v ));
277+ if (!column .isNullAt (i )) {
278+ Binary v = dictionary .decodeToBinary (dictionaryIds .getDictId (i ));
279+ column .putLong (i , ParquetRowConverter .binaryToSQLTimestamp (v ));
280+ }
267281 }
268282 } else {
269283 throw new UnsupportedOperationException ();
@@ -275,26 +289,34 @@ private void decodeDictionaryIds(int rowId, int num, ColumnVector column,
275289 // and reuse it across batches. This should mean adding a ByteArray would just update
276290 // the length and offset.
277291 for (int i = rowId ; i < rowId + num ; ++i ) {
278- Binary v = dictionary .decodeToBinary (dictionaryIds .getDictId (i ));
279- column .putByteArray (i , v .getBytes ());
292+ if (!column .isNullAt (i )) {
293+ Binary v = dictionary .decodeToBinary (dictionaryIds .getDictId (i ));
294+ column .putByteArray (i , v .getBytes ());
295+ }
280296 }
281297 break ;
282298 case FIXED_LEN_BYTE_ARRAY :
283299 // DecimalType written in the legacy mode
284300 if (DecimalType .is32BitDecimalType (column .dataType ())) {
285301 for (int i = rowId ; i < rowId + num ; ++i ) {
286- Binary v = dictionary .decodeToBinary (dictionaryIds .getDictId (i ));
287- column .putInt (i , (int ) ParquetRowConverter .binaryToUnscaledLong (v ));
302+ if (!column .isNullAt (i )) {
303+ Binary v = dictionary .decodeToBinary (dictionaryIds .getDictId (i ));
304+ column .putInt (i , (int ) ParquetRowConverter .binaryToUnscaledLong (v ));
305+ }
288306 }
289307 } else if (DecimalType .is64BitDecimalType (column .dataType ())) {
290308 for (int i = rowId ; i < rowId + num ; ++i ) {
291- Binary v = dictionary .decodeToBinary (dictionaryIds .getDictId (i ));
292- column .putLong (i , ParquetRowConverter .binaryToUnscaledLong (v ));
309+ if (!column .isNullAt (i )) {
310+ Binary v = dictionary .decodeToBinary (dictionaryIds .getDictId (i ));
311+ column .putLong (i , ParquetRowConverter .binaryToUnscaledLong (v ));
312+ }
293313 }
294314 } else if (DecimalType .isByteArrayDecimalType (column .dataType ())) {
295315 for (int i = rowId ; i < rowId + num ; ++i ) {
296- Binary v = dictionary .decodeToBinary (dictionaryIds .getDictId (i ));
297- column .putByteArray (i , v .getBytes ());
316+ if (!column .isNullAt (i )) {
317+ Binary v = dictionary .decodeToBinary (dictionaryIds .getDictId (i ));
318+ column .putByteArray (i , v .getBytes ());
319+ }
298320 }
299321 } else {
300322 throw new UnsupportedOperationException ();
0 commit comments