Median aggregation overflows for large finite middle values

Đang mở Phù hợp với người mới
#6,654 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue nà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
68/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ệ
typescript
Lĩnh vực
data

Hướng nghiên cứu

Bắt đầu với phép tính trung vị trong packages/table-core/src/features/row-aggregation/aggregationFns.ts và các bài kiểm thử hồi quy Vitest tập trung được mô tả trong issue. Kiểm tra cách phép tính xử lý các cặp giá trị hữu hạn lớn cùng với đầu vào dưới chuẩn, bằng không, NaN và vô cực. Công việc hoàn tất khi các trường hợp tràn số trả về trung vị hữu hạn và các trường hợp đối chứng được liệt kê vẫn giữ nguyên hành vi hiện tại.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

TanStack Table version

@tanstack/table-core 9.3.1, main at c14e0221b1e656c7bb35e7b3d4cdf188719a3599.

Framework/Library version

Framework-independent aggregation API; reproduced with Node 24.19.0.

Describe the bug and the steps to reproduce it

The even-length median adds the two middle values before dividing by two. That intermediate addition can overflow even when the median is finite and representable.

For example, the median of [Number.MAX_VALUE, Number.MAX_VALUE] is Number.MAX_VALUE, but the current implementation returns Infinity. The negative equivalent returns -Infinity. Unequal large finite pairs have the same issue.

The fix should also preserve tiny/subnormal results: always dividing both operands first would turn the median of [Number.MIN_VALUE, Number.MIN_VALUE] into zero. The existing zero, NaN and infinity behavior should remain unchanged.

Your Minimal, Reproducible Example

Run this with Node 24 from a checkout; this source module only has type imports and needs no framework setup:

import { aggregationFn_median } from './packages/table-core/src/features/row-aggregation/aggregationFns.ts'

const context = values => ({
  rows: values.map(value => ({ value })),
  getValue: row => row.value,
})

console.log(aggregationFn_median.aggregate(context([
  Number.MAX_VALUE,
  Number.MAX_VALUE,
]))) // Infinity; expected Number.MAX_VALUE

Source of the current median calculation.

Four focused Vitest overflow regressions fail on main, while six controls pass (opposite signs, subnormal values, ordinary numbers, signed zero and non-finite inputs).

Do you intend to try to help solve this bug with your own PR?

Yes. I am preparing a small fallback for intermediate overflow and will complete the repository's required checks before opening a PR.

Ngôn ngữ chính
TypeScript
Star
28.5k
Fork
3.6k
Merge trung bình
18 giờ 5 phút
Pull request đã merge (30 ngày)
12

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của TanStack/table

Tất cả issue của TanStack/table

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.