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

[C++] Fix incorrect child array lengths for Concatenate of FixedSizeList

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.0.0, 3.0.0
    • 3.0.0
    • C++

    Description

      When attempting to CombineChunks() on an arrow::Table containing a FixedSizeList type Array, the child arrays of the FixedSizeLists are not properly concatenated. The lengths of the child array being set incorrectly. I ran into this when trying to ToString() the combined RecordBatch.

      This seems to be because this function in :
      cpp/arrow/array/concatenate.cc

      Result<std::vector<std::shared_ptr<const ArrayData>>> ChildData(size_t index)
      

      ... used to calculate offsets and slice lengths before actual concatenation doesn't take the list lengths into account.

      The bug can be reproduced by adding the following unit test to:
      cpp/arrow/array/concatenate_test.cc

       

      TEST_F(ConcatenateTest, FixedSizeListType) {
        Check([this](int32_t size, double null_probability, std::shared_ptr<Array>* out) {
          auto list_size = 3;
          auto values_size = size * list_size;
          auto values = this->GeneratePrimitive<Int8Type>(values_size, null_probability);
          ASSERT_OK_AND_ASSIGN(*out, FixedSizeListArray::FromArrays(values, list_size));
          ASSERT_OK((**out).ValidateFull());
        });
      }
      

      One possible approach to fix this would be to add another ChildData overload to ConcatenateImpl with a multiplier parameter, and multiply the offset and length of the slice by the multiplier. This function can be called by the FixedSizeList Visitor and be supplied with the list length as multiplier.

      I have this fix ready but would like to know if this would be the right approach.

      Attachments

        Issue Links

          Activity

            People

              johanpel Johan Peltenburg
              johanpel Johan Peltenburg
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 0.5h
                  0.5h