You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@arrow.apache.org by "wjones127 (via GitHub)" <gi...@apache.org> on 2025/03/19 16:43:33 UTC

[I] [JS] Incorrect FSL values length when last element is null [arrow]

wjones127 opened a new issue, #45862:
URL: https://github.com/apache/arrow/issues/45862

   ### Describe the bug, including details regarding any error messages, version, and platform.
   
   `vectorFromArray` can produce an invalid FixedSizeList array, where the values length doesn't match the `list_size * length`. This makes other implementations error when they receive an IPC batch from JS.
   
   This only seems to happen when the null is at the end. If it's at the beginning, it works fine.
   
   ```js
   let arrow = require("apache-arrow");
   
   let badArray = arrow.vectorFromArray(
       [[1, 2, 3], null],
       new arrow.FixedSizeList(3, new  arrow.Field("item", new  arrow.Float32())),
   );
   badArray.getChildAt(0)
   ```
   ```
   Vector [FloatVector<Float>] {
     isValid: [Function (anonymous)],
     get: [Function (anonymous)],
     set: [Function (anonymous)],
     indexOf: [Function (anonymous)],
     _offsets: [ 0, 3 ],
     data: [
       Data {
         type: [Float32 [Float]],
         children: [],
         dictionary: undefined,
         offset: 0,
         length: 3,
         _nullCount: 0,
         stride: 1,
         values: [Float32Array],
         nullBitmap: Uint8Array(0) []
       }
     ],
     type: Float32 [Float] { typeId: 3, precision: 1 },
     stride: 1,
     numChildren: 0,
     length: 3 // <-- This is incorrect!
   }
   ```
   
   
   
   ```js
   let goodArray = arrow.vectorFromArray(
       [null, [1, 2, 3]],
       new arrow.FixedSizeList(3, new  arrow.Field("item", new  arrow.Float32())),
   );
   goodArray.getChildAt(0) // null
   ```
   
   ```
   Vector [FloatVector<Float>] {
     isValid: [Function (anonymous)],
     get: [Function (anonymous)],
     set: [Function (anonymous)],
     indexOf: [Function (anonymous)],
     _offsets: [ 0, 6 ],
     data: [
       Data {
         type: [Float32 [Float]],
         children: [],
         dictionary: undefined,
         offset: 0,
         length: 6,
         _nullCount: 3,
         stride: 1,
         values: [Float32Array],
         nullBitmap: [Uint8Array]
       }
     ],
     type: Float32 [Float] { typeId: 3, precision: 1 },
     stride: 1,
     numChildren: 0,
     length: 6 // Correct :)
   }
   ```
   
   We caught this when reading via IPC into arrow-rs.
   
   ### Component(s)
   
   JavaScript


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@arrow.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [JS] Incorrect FSL values length when last element is null [arrow]

Posted by "wjones127 (via GitHub)" <gi...@apache.org>.
wjones127 commented on issue #45862:
URL: https://github.com/apache/arrow/issues/45862#issuecomment-2737679125

   This can be used as a workaround:
   
   ```js
   function patchedVectorFromArray(
       data,
       type
   ) {
       // If FSL type with float
       if (arrow.DataType.isFixedSizeList(type) && arrow.DataType.isFloat(type.valueType)) {
           let extendedData = [...data, new Array(type.listSize).fill(0.0)];
           let array = arrow.vectorFromArray(extendedData, type);
           return array.slice(0, data.length);
       } else {
           return arrow.vectorFromArray(data, type);
       }
   }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [JS] Incorrect FSL values length when last element is null [arrow]

Posted by "amoeba (via GitHub)" <gi...@apache.org>.
amoeba commented on issue #45862:
URL: https://github.com/apache/arrow/issues/45862#issuecomment-2745401894

   Hi @wjones127, I put up [a PR](https://github.com/apache/arrow/pull/45889)  for this. When testing, I noticed the issue wasn't constrained to FixedSizeList<Float32> and that it was a more general behavior of the FixedSizeListBuilder. I didn't tag you as a reviewer but if you wanted to have a look that'd be very welcome.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [JS] Incorrect FSL values length when last element is null [arrow]

Posted by "amoeba (via GitHub)" <gi...@apache.org>.
amoeba commented on issue #45862:
URL: https://github.com/apache/arrow/issues/45862#issuecomment-2751197038

   Issue resolved by pull request 45889
   https://github.com/apache/arrow/pull/45889


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [JS] Incorrect FSL values length when last element is null [arrow]

Posted by "amoeba (via GitHub)" <gi...@apache.org>.
amoeba closed issue #45862: [JS] Incorrect FSL values length when last element is null
URL: https://github.com/apache/arrow/issues/45862


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org