The file reader accepts two non-delta DictionaryBatches for one id, and the column values change with no error
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 75/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- javascript, typescript
Hướng nghiên cứu
Bắt đầu tại src/ipc/reader.ts, ở _loadDictionaryBatch(), sau đó lần theo cách RecordBatchFileReader tải các lô từ điển. Bản tái hiện trong issue cho thấy một tệp có hai lô không delta cho cùng một id từ điển và các giá trị cột không chính xác. Công việc được xem là hoàn tất khi trình đọc tệp báo lỗi với trường hợp thay thế đó, trong khi các tệp hợp lệ có một lô không delta theo sau là một delta vẫn được đọc chính xác.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug, including details regarding any error messages, version, and platform.
The IPC file format allows one non-delta DictionaryBatch for each dictionary id (dictionary replacement is not supported in files), and the JS writer refuses a replacement in a file. The JS file reader accepts one. The repro writes a file whose dictionary has two chunks, so it holds a non-delta DictionaryBatch ["a", "b"] and a delta ["c"]. With the isDelta byte of the second DictionaryBatch set to 0 (each other byte stays the same), the column ["a", "b", "c"] reads as ["c", null, null], with no error.
Version and platform: apache-arrow 21.2.0, Node.js 24.22.2 on Linux (GitHub Actions), and Node.js 24.21.0 on Windows.
Repro. Save as repro.ts and run node repro.ts (Node.js 24 strips the types). It exits 1 while the fault is present. The repro also imports the generated FlatBuffers classes of apache-arrow and flatbuffers 25.9.23, to find the isDelta byte.
// F0148: apache-arrow 21.2.0. The file reader accepts two non-delta DictionaryBatches for one dictionary id. The format
// lets a file have only one non-delta DictionaryBatch for each id. RecordBatchFileReader replaces the dictionary
// with the second one, and the values of the column change with no error.
import * as A from "apache-arrow";
import { DictionaryBatch } from "apache-arrow/fb/dictionary-batch";
import { Message } from "apache-arrow/fb/message";
import * as flatbuffers from "flatbuffers";
// A dictionary of two chunks: the writer writes a non-delta DictionaryBatch ["a", "b"] and a delta ["c"].
const type = new A.Dictionary(new A.Utf8(), new A.Int32(), 0);
const dictionary = A.vectorFromArray(["a", "b"], new A.Utf8()).concat(A.vectorFromArray(["c"], new A.Utf8()));
const data = A.makeData({ type, length: 3, nullCount: 0, data: Int32Array.of(0, 1, 2), dictionary });
const file = A.tableToIPC(new A.Table({ d: A.makeVector(data) }), "file");
// The messages of a file start after the magic "ARROW1" and 2 bytes of padding, and stop at the footer.
const view = new DataView(file.buffer, file.byteOffset, file.byteLength);
const footerStart = file.length - 10 - view.getInt32(file.length - 10, true);
const isDeltaPositions: number[] = [];
let position = 8;
while (position < footerStart) {
const metadataLength = view.getInt32(position + 4, true);
if (metadataLength === 0) break;
const metadataStart = position + 8;
const message = Message.getRootAsMessage(new flatbuffers.ByteBuffer(file.subarray(metadataStart, metadataStart + metadataLength)));
const batch = message.header(new DictionaryBatch()) as DictionaryBatch | null;
if (batch && message.headerType() === A.MessageHeader.DictionaryBatch && batch.isDelta()) {
// Field 2 of the DictionaryBatch table (vtable offset 8) is isDelta.
isDeltaPositions.push(metadataStart + batch.bb_pos + batch.bb!.__offset(batch.bb_pos, 8));
}
position = metadataStart + metadataLength + Number(message.bodyLength());
}
if (isDeltaPositions.length !== 1) throw new Error(`expected one delta DictionaryBatch, found ${isDeltaPositions.length}`);
// The same file, with isDelta false in the second DictionaryBatch. Each other byte stays the same.
const twoNonDelta = file.slice();
twoNonDelta[isDeltaPositions[0]!] = 0;
const read = (bytes: Uint8Array): string => {
try {
return `d = ${JSON.stringify(Array.from(A.tableFromIPC(bytes).getChild("d") ?? []))}`;
} catch (error) {
return `throws: ${(error as Error).message}`;
}
};
console.log(`file with a non-delta and a delta DictionaryBatch: ${read(file)}`);
const result = read(twoNonDelta);
console.log(`file with two non-delta DictionaryBatches for id 0: ${result}`);
if (!result.startsWith("throws")) {
console.log("BUG PRESENT: the file reader accepts a dictionary replacement, and the values of the column change.");
process.exit(1);
}
console.log("OK: the file reader refuses a dictionary replacement.");
Output (CI run):
node: v24.22.2, os: Linux 7.0.0-1019-azure
file with a non-delta and a delta DictionaryBatch: d = ["a","b","c"]
file with two non-delta DictionaryBatches for id 0: d = ["c",null,null]
BUG PRESENT: the file reader accepts a dictionary replacement, and the values of the column change.
run.sh exit code: 1
Expected: An error from RecordBatchFileReader for a second non-delta DictionaryBatch of one id, as the format specifies for the file format.
Cause: _loadDictionaryBatch() in src/ipc/reader.ts replaces the dictionary when isDelta is false, for the stream reader and the file reader alike. The file reader has no check for a replacement.
An AI coding assistant (Claude Code) found this fault, wrote the repro and wrote this text.
- Ngôn ngữ chính
- TypeScript
- Star
- 114
- Fork
- 35
- Merge trung bình
- 13 giờ 35 phút
- Pull request đã merge (30 ngày)
- 5
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của apache/arrow-js
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
Maintainer thường phản hồi trong vòng 1 ngày
-
The IPC reader accepts a column that is shorter than its RecordBatch, and fills the missing rows with nullsCó thể đã có người làm @Sealdot đã nhận 1 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
The IPC reader ignores Schema.endianness: a big-endian stream reads 1, 2, 3 as 16777216, 33554432, 50331648Có thể đã có người làm @aniket-r2Dev2 đã nhận 2 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
tableFromIPC loops with no end on a file whose RecordBatch block points at a DictionaryBatchCó thể đã có người làm @aniket-r2Dev2 đã nhận 3 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
apache/arrow-js#547 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
The stream reader drops a message of an unexpected type but not its body, and parses the body as the next messagesCó thể đã có người làm @Umer-Butt07 đã nhận 3 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của apache/arrow-js
Issue tương tự
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 74/100
juspay/odu#193 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Add: Alfa DramasĐang mởcheck:passed streams:add
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
ready-for-agent
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maduki-tech/bautackt#4 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
moq-dev/moq#10463 · 1 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày