You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by jd...@apache.org on 2016/02/05 21:53:45 UTC

[4/5] incubator-kudu git commit: [python] - On writes, allow to set values to None

[python] - On writes, allow to set values to None

Wes pointed out that we weren't testing this case and it turns out that
it didn't work. We would crash in that case as we weren't checking for None,
which this patch now does.

Change-Id: Ic3c0e03caf76390497bcc464a1ebe508fbf33840
Reviewed-on: http://gerrit.cloudera.org:8080/2031
Reviewed-by: David Ribeiro Alves <da...@cloudera.com>
Tested-by: Kudu Jenkins
Reviewed-by: Todd Lipcon <to...@apache.org>
(cherry picked from commit 6d74508a922b8d3d8ba0518b5eb63acd10c222ae)
Reviewed-on: http://gerrit.cloudera.org:8080/2073
Reviewed-by: Jean-Daniel Cryans
Tested-by: Jean-Daniel Cryans


Project: http://git-wip-us.apache.org/repos/asf/incubator-kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-kudu/commit/015049de
Tree: http://git-wip-us.apache.org/repos/asf/incubator-kudu/tree/015049de
Diff: http://git-wip-us.apache.org/repos/asf/incubator-kudu/diff/015049de

Branch: refs/heads/branch-0.7.0
Commit: 015049de7f8cea4c4cbe67ed7a84c8d39757cb4c
Parents: 0aace44
Author: David Alves <da...@cloudera.com>
Authored: Wed Feb 3 20:09:55 2016 -0800
Committer: Jean-Daniel Cryans <jd...@gerrit.cloudera.org>
Committed: Fri Feb 5 20:51:56 2016 +0000

----------------------------------------------------------------------
 python/kudu/client.pyx            | 5 ++++-
 python/kudu/tests/test_scanner.py | 2 ++
 2 files changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/015049de/python/kudu/client.pyx
----------------------------------------------------------------------
diff --git a/python/kudu/client.pyx b/python/kudu/client.pyx
index c52c9e3..b85cd46 100644
--- a/python/kudu/client.pyx
+++ b/python/kudu/client.pyx
@@ -1155,6 +1155,10 @@ cdef class PartialRow:
             DataType t = self.table.schema.loc_type(i)
             cdef Slice* slc
 
+        if value is None:
+            self.row.SetNull(i)
+            return
+
         # Leave it to Cython to do the coercion and complain if it doesn't
         # work. Cython will catch many casting problems but we should verify
         # with unit tests.
@@ -1269,7 +1273,6 @@ cdef class Delete(WriteOperation):
         self.op = NULL
 
 
-
 cdef inline cast_pyvalue(DataType t, object o):
     if t == KUDU_BOOL:
         return BoolVal(o)

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/015049de/python/kudu/tests/test_scanner.py
----------------------------------------------------------------------
diff --git a/python/kudu/tests/test_scanner.py b/python/kudu/tests/test_scanner.py
index 63aa3ac..9699beb 100644
--- a/python/kudu/tests/test_scanner.py
+++ b/python/kudu/tests/test_scanner.py
@@ -41,6 +41,8 @@ class TestScanner(KuduTestBase, unittest.TestCase):
             op['int_val'] = tup[1]
             if i % 2 == 0:
                 op['string_val'] = tup[2]
+            elif i % 3 == 0:
+                op['string_val'] = None
             session.apply(op)
             tuples.append(tup)
         session.flush()