[Bug]: Weighted ApproximateQuantiles depends on the scale of the weights
Maintainer thường phản hồi trong vòng 2 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
- 25/100
Hướng nghiên cứu
The bug is in ApproximateQuantilesCombineFn.extract_output in the Python SDK's apache_beam/transforms/stats.py, where the offset = (total_weight - 1) / (num_quantiles - 1) term is used for weighted input. Read the docstring example and stats_test.py first, then check that weighted output stays the same when all weights are scaled. Linked PR #41560 is already open against this, so review or extend that PR instead of starting a parallel fix.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
What happened?
With weighted=True, ApproximateQuantiles gives different quantiles when every weight is multiplied by the same number, which shouldn't change a weighted quantile. Small weights give quantiles that are all the minimum:
import apache_beam as beam
from apache_beam.transforms.stats import ApproximateQuantiles
with beam.Pipeline() as p:
for w in (1, 0.5, 0.01, 0.001):
_ = (
p | f'Create {w}' >> beam.Create([(i, w) for i in range(101)])
| f'Quantiles {w}' >> ApproximateQuantiles.Globally(5, weighted=True)
| f'Print {w}' >> beam.Map(print))
# w=1 -> [0, 25, 50, 75, 100]
# w=0.5 -> [0, 24, 50, 75, 100]
# w=0.01 -> [0, 0, 25, 50, 100]
# w=0.001 -> [0, 0, 0, 0, 100]
The weighted example in the ApproximateQuantiles docstring ([(i, 1 if i<10 else 1e-5) for i in range(101)], documented output [0, 2, 5, 7, 100]) gives [0, 2, 4, 7, 100] on master. It gives the documented output only when the weights are multiplied by 1000.
ApproximateQuantilesCombineFn.extract_output uses offset = (total_weight - 1) / (num_quantiles - 1) in both cases. The - 1 turns an element count into the index of the last element, which is right without weights, but with weights it subtracts one unit of weight, so the targets move with the scale. With offset = step for the weighted case, the k-th quantile is the first element whose cumulative weight exceeds k * total_weight / (num_quantiles - 1). That gives [0, 25, 50, 75, 100] for every scale above and the documented docstring output, and the existing tests in stats_test.py still pass. I have a PR ready.
Issue Priority
Priority: 2 (default / most bugs should be filed as P2)
Issue Components
- Component: Python SDK
- Ngôn ngữ chính
- Java
- Star
- 8.7k
- Fork
- 4.8k
- Merge trung bình
- 3 ngày 16 giờ
- Pull request đã merge (30 ngày)
- 445
Chuẩn bị môi trường
- Không có Dockerfile hay 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/beam
-
awaiting triage java new feature P2
Độ 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 2 ngày
-
[Bug]: [Python] BigTableEnrichmentHandler coerces None lookup keys to literal b'None' and formats blank key name on KeyErrorCó thể đã có người làm @shikhabhadoria đã nhận 6 ngày trước. Đang mởio P2 python
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
apache/beam#41346 · 4 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Release notes links wrongCó thể đã có người làm @schizophrenicmaniac đã nhận 20 ngày trước. Đang mởbug P3
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 67/100
apache/beam#41197 · 3 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
apache/beam#39624 · 2 reaction ·
Maintainer thường phản hồi trong vòng 2 ngày
-
[Bug]: PubsubIO used in batch incorrect batch cutoff sizeCó thể đã có người làm @1fanwang đã nhận 98 ngày trước. Đang mởbug io P3 pinned pubsub
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
apache/beam#28011 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
Issue tương tự
-
`ovsx verify` fails for a version older than the 100 newest of an extensionCó thể đã có người làm @trivikr đã nhận hôm nay. Đang mởcli
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 81/100
eclipse-openvsx/openvsx#2482 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
32x and 48x Item Model IssuesĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
Magic-team-jvav/confluence#281 ·
-
CVE-2026-139999 react-routerĐang mởarea/dependencies area/dependencies/js backport/26.6 backport/26.8 kind/cve severity/medium source/scan-dependencies status/triage
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 67/100
Maintainer thường phản hồi trong vòng 2 ngày
-
[DEFECT] AsciiDoc builders write a stray ## before every schema member when the namespace prefixes file binds the schema's own namespaceCó thể đã có người làm @Beehtrix đã nhận hôm nay. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
cimug-org/CIMTool#427 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
userRaised
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
eclipse-openj9/openj9#25285 ·
Maintainer thường phản hồi trong vòng 1 ngày