Uploaded image for project: 'Apache Arrow'
  1. Apache Arrow
  2. ARROW-6425

[C++] ValidateArray fail for slice of list array

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 0.14.1
    • 0.15.0
    • C++
    • None

    Description

      The ValidateArray function fails for slice of list array (and MapArray I believe though haven't tested it yet). The validation will only pass for an unsliced array or the last slice.

       

      For example,

       

       

      auto value_builder = std::make_shared<::arrow::DoubleBuilder>();
          ::arrow::ListBuilder builder(
              ::arrow::default_memory_pool(), value_builder);
          auto status = builder.Append(true);
          status = value_builder->Append(1);
          status = builder.Append(true);
          status = value_builder->Append(2);
          std::shared_ptr<::arrow::Array> list;
          status = builder.Finish(&list);
          std::cout << ::arrow::ValidateArray(*list).ok() << std::endl;
          std::cout << ::arrow::ValidateArray(*list->Slice(0, 1)).ok() << std::endl;
          std::cout << ::arrow::ValidateArray(*list->Slice(1, 1)).ok() << std::endl;
       

       

      This will print 1, 0, 1.

       

      The problem lies in array.cc around line 1167

       

          const int32_t last_offset = array.value_offset(array.length());
          if (array.values()->length() != last_offset) {
            return Status::Invalid("Final offset invariant not equal to values length: ",
                                   last_offset, "!=", array.values()->length());
          }
      

      Here values() does not account for the array offset and thus its length is the whole array while value_offset and array.length() will account for that offset.

      Attachments

        Issue Links

          Activity

            People

              wesm Wes McKinney
              zhouyan Yan Zhou
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: