Repository navigation
Fix table parse: combined column - #17039
Conversation
📝 WalkthroughWalkthroughTable ingestion now deduplicates repeated headers across Excel, TXT, and CSV inputs. Chunk schema inference also normalizes duplicate columns, and a regression test verifies generated content and parser configuration use the resulting unique names. ChangesTable column deduplication
Estimated code review effort: 3 (Moderate) | ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
rag/app/table.py (1)
476-478: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRemove redundant deduplication check.
Because
_deduplicate_column_namesis already applied during DataFrame construction for Excel, TXT, and CSV formats (lines 121, 429, and 452), the columns indfsare guaranteed to be unique. This fallback check is functionally dead code and can be removed.♻️ Proposed fix
clmns = df.columns.values - if len(clmns) != len(set(clmns)): - df.columns = _deduplicate_column_names(clmns) - clmns = df.columns.values txts = list(copy.deepcopy(clmns))🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@rag/app/table.py` around lines 476 - 478, Remove the redundant duplicate-column check and reassignment block around _deduplicate_column_names in the DataFrame processing flow, since construction already guarantees unique columns for the supported formats. Preserve the existing clmns and df processing behavior without adding another fallback deduplication path.test/unit_test/rag/app/test_table_chunk_column_roles.py (1)
127-127: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRemove unused variable
kwargs.Static analysis indicates that the unpacked variable
kwargsis never used. Prefix it with an underscore to improve code cleanliness.♻️ Proposed fix
- args, kwargs = mock_update_kb.call_args + args, _kwargs = mock_update_kb.call_args🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test/unit_test/rag/app/test_table_chunk_column_roles.py` at line 127, Update the mock_update_kb.call_args unpacking in the test to bind the unused keyword-arguments value to an underscore-prefixed variable, while preserving the existing args usage.Source: Linters/SAST tools
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@rag/app/table.py`:
- Around line 476-478: Remove the redundant duplicate-column check and
reassignment block around _deduplicate_column_names in the DataFrame processing
flow, since construction already guarantees unique columns for the supported
formats. Preserve the existing clmns and df processing behavior without adding
another fallback deduplication path.
In `@test/unit_test/rag/app/test_table_chunk_column_roles.py`:
- Line 127: Update the mock_update_kb.call_args unpacking in the test to bind
the unused keyword-arguments value to an underscore-prefixed variable, while
preserving the existing args usage.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 2b075bd4-b1b8-4e89-9528-af79d3c80a75
📒 Files selected for processing (2)
rag/app/table.pytest/unit_test/rag/app/test_table_chunk_column_roles.py
wangq8
left a comment
There was a problem hiding this comment.
Review: PR #17039
Overview: Replaces the previous ValueError-on-duplicate-columns behavior with automatic deduplication via suffix-based renaming (_2, _3, ...). Applied consistently across Excel, TXT, CSV parsers and schema inference. 49 additions, 6 deletions.
✅ Correctness
The _deduplicate_column_names logic is well-crafted:
- Uses both a
usedset (tracking what has been assigned) and areservedset (all original names). This prevents suffixed names from colliding with any existing column name, even ones that appear later in the sequence. Example:["name", "name_2", "name"]correctly yields["name", "name_2", "name_3"]. - The
Counter-based suffix ensures the first duplicate gets_2, then_3, etc., regardless of insertion order.
Trace through the test fixture ["name", "name", "name_2"]:
"name"→ added as-is"name"→ tries"name_2"but conflicts with originalreserved→ escalates to"name_3""name_2"→ added as-is (unique)
Result:["name", "name_3", "name_2"]✅ — matches the test assertion.
🔍 Issues
1. 🟡 Redundant fallback check (lines ~476-478)
CodeRabbit correctly flagged this. Since all three entry points (Excel, TXT, CSV) already apply _deduplicate_column_names during DataFrame construction, columns entering the schema inference loop are guaranteed unique. The if len(clmns) != len(set(clmns)): guard and its _deduplicate_column_names call are dead code. Consider removing it for clarity.
2. 🔵 Missing docstring
The new _deduplicate_column_names function has no docstring. Given it has non-trivial collision-avoidance logic, a short docstring explaining the deduplication strategy (especially the reserved set) would help future readers.
3. 🔵 No PR description
An empty PR body makes it harder to review intent. Would be good to add a Summary section explaining the problem (e.g., "files with duplicate column headers crash the parser") and the chosen fix.
✅ Verdict: Approve 🚀
Minor issues only — none are correctness blockers. The change is a clear improvement over the previous crash-on-duplicates behavior, the deduplication logic handles edge cases well, and the test covers a realistic scenario. Good work.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #17039 +/- ##
==========================================
- Coverage 94.56% 93.16% -1.40%
==========================================
Files 10 10
Lines 717 717
Branches 118 118
==========================================
- Hits 678 668 -10
- Misses 25 29 +4
- Partials 14 20 +6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
No description provided.