Skip to content

[Fix] Remap failed-measurement indices when reordering insert columns - #18819

Merged
JackieTien97 merged 2 commits into
masterfrom
fix/remap-failed-measurement-index-after-column-reorder
Oct 11, 2026
Merged

JackieTien97 merged 2 commits into
masterfrom
fix/remap-failed-measurement-index-after-column-reorder

Conversation

@shuwenwei

Copy link
Copy Markdown
Member

Problem

failedMeasurementIndex2Info maps a column index to the info of a measurement whose value failed partial-insert handling. When the insert columns are later reordered to match the schema's TAG order, this map is not updated:

  • InsertBaseStatement.swapColumn(src, target) swaps the measurement arrays but leaves the map keys untouched.
  • InsertBaseStatement.rebuildArraysAfterExpansion(newToOldMapping, ...) rebuilds the arrays from newToOldMapping but leaves the map keys untouched.

The map therefore no longer describes the final measurements array. Any consumer that pairs the map with the arrays by index is then wrong, e.g.:

  • LogicalPlanVisitor marks the failed measurement on the InsertRowNode by the (stale) index.
  • removeAllFailedMeasurementMarks() restores the wrong column name / data type / value.
  • Downstream code that recovers a nulled column name from the map by index (e.g. write-label collection, PipeConverted*Statement) resolves the wrong column (or none).

Note that InsertBaseStatement.removeAttributeColumns() already remaps failedMeasurementIndex2Info when it drops columns, so the missing remap in swapColumn / rebuildArraysAfterExpansion is an inconsistency in the same data structure.

Fix

  • swapColumn(src, target) now swaps the two corresponding entries of failedMeasurementIndex2Info.
  • rebuildArraysAfterExpansion(...) now rewrites the map keys from the old indices to the new ones described by newToOldMapping (newToOldMapping[newIdx] = oldIdx); entries whose old index is -1 (an appended missing TAG column) have no failure record and are naturally skipped.

Both are additive, behavior-preserving for the non-reordered case (the map is empty or already aligned).

Tests

Added to InsertStatementPartialInsertTest:

  • testSwapColumnRemapsFailedMeasurementIndex
  • testRebuildArraysAfterExpansionRemapsFailedMeasurementIndex

@codecov

codecov Bot commented Oct 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.83333% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 45.82%. Comparing base (f16e5b3) to head (ad48b58).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...ngine/plan/statement/crud/InsertBaseStatement.java 95.83% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #18819      +/-   ##
============================================
- Coverage     45.82%   45.82%   -0.01%     
  Complexity      712      712              
============================================
  Files          5498     5498              
  Lines        397637   397661      +24     
  Branches      51765    51770       +5     
============================================
- Hits         182235   182231       -4     
- Misses       215402   215430      +28     

☔ View full report in Codecov by Harness.
📢 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.

@JackieTien97
JackieTien97 merged commit 6819c8b into master Oct 11, 2026
37 of 40 checks passed
@JackieTien97
JackieTien97 deleted the fix/remap-failed-measurement-index-after-column-reorder branch October 11, 2026 06:10
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.

2 participants