Skip to content

Fix table parse: combined column - #17039

Merged
wangq8 merged 2 commits into
infiniflow:mainfrom
wangq8:bugfix/fix-table-combined-column
Jul 17, 2026
Merged

wangq8 merged 2 commits into
infiniflow:mainfrom
wangq8:bugfix/fix-table-combined-column

Conversation

@wangq8

@wangq8 wangq8 commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

@wangq8 wangq8 added the ci Continue Integration label Jul 17, 2026
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. 🐞 bug Something isn't working, pull request that fix bug. labels Jul 17, 2026
@coderabbitai

coderabbitai Bot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Table 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.

Changes

Table column deduplication

Layer / File(s) Summary
Column deduplication across parsers
rag/app/table.py
Adds shared suffix-based column-name deduplication and applies it during Excel, TXT, CSV, and chunk schema processing.
Duplicate-header chunk validation
test/unit_test/rag/app/test_table_chunk_column_roles.py
Adds a repeated-header CSV fixture and verifies deduplicated chunk content and parser configuration names.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Poem

A rabbit saw headers repeat in a row,
So gave each a suffix, neat as snow.
Excel and CSV joined the dance,
TXT found its columns’ second chance.
Tests thumped: “Unique names now!” 🐇

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning No PR description was provided, so the required Summary section and background context are missing. Add the required Summary section with the problem context, what changed, and why this table parsing fix was needed.
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately points to the table parse change around combined columns.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
rag/app/table.py (1)

476-478: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Remove redundant deduplication check.

Because _deduplicate_column_names is already applied during DataFrame construction for Excel, TXT, and CSV formats (lines 121, 429, and 452), the columns in dfs are 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 value

Remove unused variable kwargs.

Static analysis indicates that the unpacked variable kwargs is 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

📥 Commits

Reviewing files that changed from the base of the PR and between e55bc96 and af197ef.

📒 Files selected for processing (2)
  • rag/app/table.py
  • test/unit_test/rag/app/test_table_chunk_column_roles.py

@wangq8 wangq8 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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 used set (tracking what has been assigned) and a reserved set (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"]:

  1. "name" → added as-is
  2. "name" → tries "name_2" but conflicts with original reserved → escalates to "name_3"
  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

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.16%. Comparing base (7c698f8) to head (af197ef).
⚠️ Report is 16 commits behind head on main.

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.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@wangq8
wangq8 merged commit 6a1224b into infiniflow:main Jul 17, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant