Repository: kudu
Updated Branches:
  refs/heads/master a03a2f380 -> 1c4dcabdd


KUDU-1637 - [python] Add Support for < and > Predicates

Currently the python client doesn't support < and > predicates.
This patch adds that support and includes changes to existing tests.

Change-Id: Ic78dcf58949277fc8363d4d5b3bfa6067932a823
Reviewed-on: http://gerrit.cloudera.org:8080/4524
Tested-by: Kudu Jenkins
Reviewed-by: David Ribeiro Alves <[email protected]>


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

Branch: refs/heads/master
Commit: 01bf011cd49e132a8333bf8ea7272b8354e8cab2
Parents: a03a2f3
Author: Jordan Birdsell <[email protected]>
Authored: Thu Sep 22 22:18:06 2016 -0500
Committer: Todd Lipcon <[email protected]>
Committed: Wed Sep 28 04:26:08 2016 +0000

----------------------------------------------------------------------
 python/kudu/client.pyx              | 6 +++++-
 python/kudu/libkudu_client.pxd      | 2 ++
 python/kudu/tests/test_scanner.py   | 2 +-
 python/kudu/tests/test_scantoken.py | 2 +-
 4 files changed, 9 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/01bf011c/python/kudu/client.pyx
----------------------------------------------------------------------
diff --git a/python/kudu/client.pyx b/python/kudu/client.pyx
index 800a620..bd37d2b 100644
--- a/python/kudu/client.pyx
+++ b/python/kudu/client.pyx
@@ -768,10 +768,14 @@ cdef class Column:
                                    len(self.name))
 
         try:
-            if op == 1: # <=
+            if op == 0: # <
+                cmp_op = KUDU_LESS
+            elif op == 1: # <=
                 cmp_op = KUDU_LESS_EQUAL
             elif op == 2: # ==
                 cmp_op = KUDU_EQUAL
+            elif op == 4: # >
+                cmp_op = KUDU_GREATER
             elif op == 5: # >=
                 cmp_op = KUDU_GREATER_EQUAL
             else:

http://git-wip-us.apache.org/repos/asf/kudu/blob/01bf011c/python/kudu/libkudu_client.pxd
----------------------------------------------------------------------
diff --git a/python/kudu/libkudu_client.pxd b/python/kudu/libkudu_client.pxd
index 11bc78d..091f326 100644
--- a/python/kudu/libkudu_client.pxd
+++ b/python/kudu/libkudu_client.pxd
@@ -423,6 +423,8 @@ cdef extern from "kudu/client/scan_predicate.h" namespace 
"kudu::client" nogil:
         KUDU_LESS_EQUAL    " kudu::client::KuduPredicate::LESS_EQUAL"
         KUDU_GREATER_EQUAL " kudu::client::KuduPredicate::GREATER_EQUAL"
         KUDU_EQUAL         " kudu::client::KuduPredicate::EQUAL"
+        KUDU_LESS          " kudu::client::KuduPredicate::LESS"
+        KUDU_GREATER       " kudu::client::KuduPredicate::GREATER"
 
     cdef cppclass KuduPredicate:
         KuduPredicate* Clone()

http://git-wip-us.apache.org/repos/asf/kudu/blob/01bf011c/python/kudu/tests/test_scanner.py
----------------------------------------------------------------------
diff --git a/python/kudu/tests/test_scanner.py 
b/python/kudu/tests/test_scanner.py
index 3cfe80e..b1d8505 100644
--- a/python/kudu/tests/test_scanner.py
+++ b/python/kudu/tests/test_scanner.py
@@ -43,7 +43,7 @@ class TestScanner(TestScanBase):
 
     def test_scan_rows_simple_predicate(self):
         key = self.table['key']
-        preds = [key >= 20, key <= 49]
+        preds = [key > 19, key < 50]
 
         def _read_predicates(preds):
             scanner = self.table.scanner()

http://git-wip-us.apache.org/repos/asf/kudu/blob/01bf011c/python/kudu/tests/test_scantoken.py
----------------------------------------------------------------------
diff --git a/python/kudu/tests/test_scantoken.py 
b/python/kudu/tests/test_scantoken.py
index 415c949..d3aff74 100644
--- a/python/kudu/tests/test_scantoken.py
+++ b/python/kudu/tests/test_scantoken.py
@@ -76,7 +76,7 @@ class TestScanToken(TestScanBase):
         them in parallel with seperate clients.
         """
         key = self.table['key']
-        preds = [key >= 20, key <= 49]
+        preds = [key > 19, key < 50]
 
         builder = self.table.scan_token_builder()
         builder.set_projected_column_indexes([0, 1])\

Reply via email to