You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "rustyconover (via GitHub)" <gi...@apache.org> on 2026/03/04 14:03:29 UTC

[PR] fix: Pass explicit length in Struct makeData calls [arrow-js]

rustyconover opened a new pull request, #404:
URL: https://github.com/apache/arrow-js/pull/404

   ## Summary
   - Pass `length: data.length` in `setChildAt` to preserve the batch's row count when constructing Struct data
   - Pass `length: 0` explicitly in `_InternalEmptyPlaceholderRecordBatch` instead of relying on reduce-over-children fallback
   - Add tests for Struct `makeData` with empty children and `setChildAt` row count preservation
   
   Closes #403
   
   ## Test plan
   - [x] `makeData` with empty children preserves explicit length
   - [x] `makeData` with empty children and no length defaults to 0
   - [x] `setChildAt` preserves `numRows` after column replacement
   - [x] Full test suite passes (`yarn test -t src`)
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


-- 
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: [PR] fix: Pass explicit length in Struct makeData calls [arrow-js]

Posted by "trxcllnt (via GitHub)" <gi...@apache.org>.
trxcllnt commented on code in PR #404:
URL: https://github.com/apache/arrow-js/pull/404#discussion_r2887710595


##########
test/unit/data/struct-zero-children-tests.ts:
##########
@@ -0,0 +1,55 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+import '../../jest-extensions.js';
+
+import {
+    makeData, makeVector,
+    Schema, Field, RecordBatch,
+    Struct, Int32
+} from 'apache-arrow';
+
+describe('Struct with zero children', () => {
+
+    test('makeData with empty children preserves explicit length', () => {
+        const data = makeData({ type: new Struct([]), length: 50, nullCount: 0, children: [] });
+        expect(data).toHaveLength(50);

Review Comment:
   I have the same question here as https://github.com/apache/arrow-js/pull/402#pullrequestreview-3893887624.



-- 
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: [PR] fix: Pass explicit length in Struct makeData calls [arrow-js]

Posted by "kou (via GitHub)" <gi...@apache.org>.
kou merged PR #404:
URL: https://github.com/apache/arrow-js/pull/404


-- 
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: [PR] fix: Pass explicit length in Struct makeData calls [arrow-js]

Posted by "rustyconover (via GitHub)" <gi...@apache.org>.
rustyconover commented on code in PR #404:
URL: https://github.com/apache/arrow-js/pull/404#discussion_r2887785271


##########
test/unit/data/struct-zero-children-tests.ts:
##########
@@ -0,0 +1,55 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+import '../../jest-extensions.js';
+
+import {
+    makeData, makeVector,
+    Schema, Field, RecordBatch,
+    Struct, Int32
+} from 'apache-arrow';
+
+describe('Struct with zero children', () => {
+
+    test('makeData with empty children preserves explicit length', () => {
+        const data = makeData({ type: new Struct([]), length: 50, nullCount: 0, children: [] });
+        expect(data).toHaveLength(50);

Review Comment:
   See the reply there, this bug was discovered in the same use case.



-- 
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