Repository: kudu Updated Branches: refs/heads/master 10f525519 -> 29f1543cc
python: allow passing single strings instead of lists in more places Several of our APIs take lists of column names, but it's easy to accidentally just pass a string. If we naively iterate over the string, we end up interpreting "foo" as ["f", "o", "o"] which is obviously incorrect. This patch takes the approach of detecting the string argument and converting to a singleton list. An alternative would have been to raise TypeError, but it seems like we do this conversion in other places, so I decided to be consistent. Change-Id: I1a81dea5356b66b8860d22f9ee2935072fd4cd6c Reviewed-on: http://gerrit.cloudera.org:8080/5019 Tested-by: Kudu Jenkins Reviewed-by: Jordan Birdsell <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/kudu/repo Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/29f1543c Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/29f1543c Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/29f1543c Branch: refs/heads/master Commit: 29f1543cc62793c58ee6ba73a48089b6e2d49e7b Parents: 10f5255 Author: Todd Lipcon <[email protected]> Authored: Wed Nov 9 10:24:22 2016 -0800 Committer: Jordan Birdsell <[email protected]> Committed: Wed Nov 9 20:43:21 2016 +0000 ---------------------------------------------------------------------- python/kudu/client.pyx | 6 ++++++ 1 file changed, 6 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/kudu/blob/29f1543c/python/kudu/client.pyx ---------------------------------------------------------------------- diff --git a/python/kudu/client.pyx b/python/kudu/client.pyx index cec61ff..328c127 100644 --- a/python/kudu/client.pyx +++ b/python/kudu/client.pyx @@ -1023,6 +1023,8 @@ class Partitioning(object): ------- self: this object """ + if isinstance(column_names, str): + column_names = [column_names] self._range_partition_cols = column_names return self @@ -1464,6 +1466,8 @@ cdef class Scanner: ------- self : Scanner """ + if isinstance(names, str): + names = [names] cdef vector[string] v_names for name in names: v_names.push_back(tobytes(name)) @@ -1930,6 +1934,8 @@ cdef class ScanTokenBuilder: ------- self : ScanTokenBuilder """ + if isinstance(names, str): + names = [names] cdef vector[string] v_names for name in names: v_names.push_back(tobytes(name))
