You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ks...@apache.org on 2018/12/22 23:43:50 UTC

[arrow] branch master updated: ARROW-4101: [C++] Identity BinaryType cast

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

kszucs pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/master by this push:
     new ffc8877  ARROW-4101: [C++] Identity BinaryType cast
ffc8877 is described below

commit ffc8877aa6c2d80418cb805076fc0545e6b0204c
Author: Krisztián Szűcs <sz...@gmail.com>
AuthorDate: Sun Dec 23 00:43:38 2018 +0100

    ARROW-4101: [C++] Identity BinaryType cast
    
    Author: Krisztián Szűcs <sz...@gmail.com>
    Author: François Saint-Jacques <fs...@gmail.com>
    
    Closes #3245 from fsaintjacques/ARROW-4101-cast-identity and squashes the following commits:
    
    4bb2fb7b <Krisztián Szűcs> parametrize
    4319bace <François Saint-Jacques> ARROW-4101:  Identity BinaryType cast
---
 cpp/src/arrow/compute/kernels/cast.cc |  4 +++-
 python/pyarrow/tests/test_array.py    | 20 ++++++++++++++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/cpp/src/arrow/compute/kernels/cast.cc b/cpp/src/arrow/compute/kernels/cast.cc
index 2ce0702..7976ef0 100644
--- a/cpp/src/arrow/compute/kernels/cast.cc
+++ b/cpp/src/arrow/compute/kernels/cast.cc
@@ -1258,7 +1258,9 @@ class CastKernel : public UnaryKernel {
   FN(TimestampType, Date64Type);     \
   FN(TimestampType, Int64Type);
 
-#define BINARY_CASES(FN, IN_TYPE) FN(BinaryType, StringType);
+#define BINARY_CASES(FN, IN_TYPE) \
+  FN(BinaryType, BinaryType);     \
+  FN(BinaryType, StringType);
 
 #define STRING_CASES(FN, IN_TYPE) \
   FN(StringType, StringType);     \
diff --git a/python/pyarrow/tests/test_array.py b/python/pyarrow/tests/test_array.py
index 352c855..3d34021 100644
--- a/python/pyarrow/tests/test_array.py
+++ b/python/pyarrow/tests/test_array.py
@@ -755,6 +755,26 @@ def test_cast_date64_to_int():
     assert result.equals(expected)
 
 
+@pytest.mark.parametrize(('ty', 'values'), [
+    ('bool', [True, False, True]),
+    ('uint8', range(0, 255)),
+    ('int8', range(0, 128)),
+    ('uint16', range(0, 10)),
+    ('int16', range(0, 10)),
+    ('uint32', range(0, 10)),
+    ('int32', range(0, 10)),
+    ('uint64', range(0, 10)),
+    ('int64', range(0, 10)),
+    ('float', [0.0, 0.1, 0.2]),
+    ('double', [0.0, 0.1, 0.2]),
+    ('string', ['a', 'b', 'c']),
+    ('binary', [b'a', b'b', b'c'])
+])
+def test_cast_identities(ty, values):
+    arr = pa.array(values, type=ty)
+    assert arr.cast(ty).equals(arr)
+
+
 pickle_test_parametrize = pytest.mark.parametrize(
     ('data', 'typ'),
     [