You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iceberg.apache.org by dw...@apache.org on 2019/08/14 19:40:30 UTC

[incubator-iceberg] branch master updated: Handle nulls in Conversions. (#383)

This is an automated email from the ASF dual-hosted git repository.

dweeks pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-iceberg.git


The following commit(s) were added to refs/heads/master by this push:
     new 94decf2  Handle nulls in Conversions. (#383)
94decf2 is described below

commit 94decf286534f87a018a727ab0d7aee583c721c4
Author: Ryan Blue <rd...@users.noreply.github.com>
AuthorDate: Wed Aug 14 12:40:26 2019 -0700

    Handle nulls in Conversions. (#383)
---
 api/src/main/java/org/apache/iceberg/types/Conversions.java | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/api/src/main/java/org/apache/iceberg/types/Conversions.java b/api/src/main/java/org/apache/iceberg/types/Conversions.java
index e2c728d..3b3de61 100644
--- a/api/src/main/java/org/apache/iceberg/types/Conversions.java
+++ b/api/src/main/java/org/apache/iceberg/types/Conversions.java
@@ -78,6 +78,10 @@ public class Conversions {
       ThreadLocal.withInitial(StandardCharsets.UTF_8::newDecoder);
 
   public static ByteBuffer toByteBuffer(Type type, Object value) {
+    if (value == null) {
+      return null;
+    }
+
     switch (type.typeId()) {
       case BOOLEAN:
         return ByteBuffer.allocate(1).put(0, (Boolean) value ? (byte) 0x01 : (byte) 0x00);
@@ -120,6 +124,10 @@ public class Conversions {
   }
 
   private static Object internalFromByteBuffer(Type type, ByteBuffer buffer) {
+    if (buffer == null) {
+      return null;
+    }
+
     ByteBuffer tmp = buffer.duplicate();
     if (type == Types.UUIDType.get() || type instanceof Types.DecimalType) {
       tmp.order(ByteOrder.BIG_ENDIAN);