You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by uw...@apache.org on 2018/05/12 07:20:18 UTC

[arrow] branch master updated: ARROW-2567: [C++] Not only compare type ids on Array equality

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

uwe 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 321773c  ARROW-2567: [C++] Not only compare type ids on Array equality
321773c is described below

commit 321773c094ba91ec90b0c5c296d85492034caf43
Author: Korn, Uwe <Uw...@blue-yonder.com>
AuthorDate: Sat May 12 09:20:11 2018 +0200

    ARROW-2567: [C++] Not only compare type ids on Array equality
    
    Author: Korn, Uwe <Uw...@blue-yonder.com>
    
    Closes #2025 from xhochy/ARROW-2567 and squashes the following commits:
    
    2db252ae <Korn, Uwe> ARROW-2567:  Not only compare type ids on Array equality
---
 cpp/src/arrow/array-test.cc | 11 +++++++++++
 cpp/src/arrow/compare.cc    |  5 +++++
 2 files changed, 16 insertions(+)

diff --git a/cpp/src/arrow/array-test.cc b/cpp/src/arrow/array-test.cc
index 0095832..39847e0 100644
--- a/cpp/src/arrow/array-test.cc
+++ b/cpp/src/arrow/array-test.cc
@@ -100,6 +100,17 @@ TEST_F(TestArray, TestEquality) {
   EXPECT_FALSE(array->RangeEquals(0, 4, 0, unequal_array));
   EXPECT_FALSE(array->RangeEquals(0, 8, 0, unequal_array));
   EXPECT_FALSE(array->RangeEquals(1, 2, 1, unequal_array));
+
+  auto timestamp_ns_array = std::make_shared<NumericArray<TimestampType>>(
+      timestamp(TimeUnit::NANO), array->length(), array->data()->buffers[1],
+      array->data()->buffers[0], array->null_count());
+  auto timestamp_us_array = std::make_shared<NumericArray<TimestampType>>(
+      timestamp(TimeUnit::MICRO), array->length(), array->data()->buffers[1],
+      array->data()->buffers[0], array->null_count());
+  ASSERT_FALSE(array->Equals(timestamp_ns_array));
+  // ARROW-2567: Ensure that not only the type id but also the type equality
+  // itself is checked.
+  ASSERT_FALSE(timestamp_us_array->Equals(timestamp_ns_array));
 }
 
 TEST_F(TestArray, TestNullArrayEquality) {
diff --git a/cpp/src/arrow/compare.cc b/cpp/src/arrow/compare.cc
index 51d8aee..7a84b14 100644
--- a/cpp/src/arrow/compare.cc
+++ b/cpp/src/arrow/compare.cc
@@ -533,6 +533,11 @@ static bool BaseDataEquals(const Array& left, const Array& right) {
       left.type_id() != right.type_id()) {
     return false;
   }
+  // ARROW-2567: Ensure that not only the type id but also the type equality
+  // itself is checked.
+  if (!TypeEquals(*left.type(), *right.type())) {
+    return false;
+  }
   if (left.null_count() > 0 && left.null_count() < left.length()) {
     return BitmapEquals(left.null_bitmap()->data(), left.offset(),
                         right.null_bitmap()->data(), right.offset(), left.length());

-- 
To stop receiving notification emails like this one, please contact
uwe@apache.org.