fix(market_metrics): disambiguate ROLLUP grand-total via GROUPING() (#1214) #1258
No reviewers
Labels
No labels
admin
analytics
auth
automation
bug
business
chore
ci
compliance
data
data-moat
docs
duplicate
dx
enhancement
Fable 5 ревью
feedback/max
generative
GG-форсайт
needs-discussion
needs-human
observability
pause-bots
performance
priority/p0
priority/p1
priority/p2
priority/p3
scope/backend
scope/db
scope/devops
scope/frontend
scope/qa
scrapers
security
site-finder
stage/1
stage/2
status/blocked
status/done
status/needs-analysis
status/needs-fix
status/qa
status/ready
status/review
status/wip
tech-debt
tradein
ux
week ревью 1
wontfix
вторичка
ИРД
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: lekss361/gendesign#1258
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "fix/market-metrics-rollup-grand-total-disambiguate"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Closes #1214 (P2 correctness — silent data corruption в форсайте). ROLLUP grand-total путали с NULL-комнатной группой →
units_totalзатирался частичным счётом.Bug
_SALES_WINDOW_SQLделаетGROUP BY ROLLUP (rooms_int),rooms_intnullable (ETL пишет NULL для «неопределённого типа»,sales_series.py:399явно обрабатывает None).Один проданный лот с
rooms_int IS NULLдаёт ДВЕ строки сrooms_int IS NULL(NULL-группа + grand-total итог), неразличимые в Python (if r["rooms_int"] is None).MixedAggregate-план PG16 эмитит grand-total ПЕРВЫМ среди hash-строк, NULL-группа после → loop затирает
units_totalчастичным счётом (живой тест на PG16: 2000 → 200).Эффект:
unit_velocity,absorption_rateзанижены,months_of_supplyзавышен →base_paceвdemand_supply_forecastневерный → reports/scoring врёт.Fix
GROUPING(rooms_int) AS is_total(=1 для grand-total, =0 иначе).is_total, NULL-комнатную группу класть вby_room['unknown'](отдельный бакет), аккумулировать через+=вместо assign (защита от будущих NULL-вариантов).is_totalполе.Test plan
pytest -k market_metrics→ 71 passed, 1 skipped.ruff check→ clean.units_totalкорректно ≈ полная сумма;by_room['unknown']> 0 если есть такие лоты.Closes #1214