Skip to content

BOT: Fix #382: Warn when metric names clash with existing column names#1100

Draft
nikosbosse wants to merge 1 commit intomainfrom
fix/382-metric-column-clash
Draft

BOT: Fix #382: Warn when metric names clash with existing column names#1100
nikosbosse wants to merge 1 commit intomainfrom
fix/382-metric-column-clash

Conversation

@nikosbosse
Copy link
Collaborator

Summary

  • Fixes Feature: Input check to notify about clashes with metrics and column names #382
  • Adds a check in apply_metrics() that warns when metric names match existing column names in the forecast data, which would cause silent data overwriting
  • Previously, apply_metrics() would silently overwrite forecast columns (including forecast unit columns like horizon, model, or even protected columns like observed) when a user-provided metric had the same name

Root Cause

apply_metrics() assigns metric results to the forecast data.table using forecast[, (metric_name) := result]. If metric_name matches an existing column, that column is silently overwritten, corrupting the forecast data with no warning.

What the fix does

Adds an intersect(names(metrics), colnames(forecast)) check at the top of apply_metrics() that emits a cli_warn() listing all clashing column names. The warning is informational — scoring still proceeds. This single check covers all 7 forecast types since they all call apply_metrics().

Test coverage added

7 new tests in test-score.R:

  • Clash detection for binary, quantile, sample, and point forecast types
  • No false-positive warning when metrics don't clash
  • Multiple simultaneous clashes reported in a single warning
  • Protected column name (observed) clash detected

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Feb 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.84%. Comparing base (ac0c01a) to head (09d4daf).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1100   +/-   ##
=======================================
  Coverage   97.83%   97.84%           
=======================================
  Files          35       35           
  Lines        1845     1853    +8     
=======================================
+ Hits         1805     1813    +8     
  Misses         40       40           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator Author

@nikosbosse nikosbosse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CLAUDE: Approve — Clean, minimal fix. The clash detection is correctly placed in apply_metrics() to protect all 7 forecast types with a single intersect() check. The cli_warn() message is clear and actionable. All 7 tests match the specifications and cover the key scenarios (per-type clash, no false positive, multiple clashes, protected column clash). Existing apply_metrics() tests correctly updated to use fresh data.tables to avoid false positives from the new check. No issues found.

@nikosbosse nikosbosse marked this pull request as draft February 13, 2026 08:28
@nikosbosse nikosbosse changed the title Fix #382: Warn when metric names clash with existing column names BOT: Fix #382: Warn when metric names clash with existing column names Feb 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Input check to notify about clashes with metrics and column names

1 participant

Comments