Skip to content

fix: preserve extra_columns field on ragged CSV rows - #13001

Closed
ansh-rohilla wants to merge 1 commit into
deepset-ai:mainfrom
ansh-rohilla:fix/csv-ragged-row-extra-columns
Closed

ansh-rohilla wants to merge 1 commit into
deepset-ai:mainfrom
ansh-rohilla:fix/csv-ragged-row-extra-columns

Conversation

@ansh-rohilla

@ansh-rohilla ansh-rohilla commented Sep 28, 2026 •

Copy link
Copy Markdown

Related Issues

Proposed Changes:

In row mode, CSVToDocument previously configured csv.DictReader with restkey="extra_columns". If the CSV file contained an actual header column named extra_columns, ragged rows with surplus fields overwrote the cell's actual value with the overflow list.

This PR:

  • Uses a private sentinel object (_RAGGED_ROW_RESTKEY = object()) for DictReader.restkey so it never collides with any CSV header.
  • Maps surplus fields to "extra_columns" during metadata construction, ensuring that if a real extra_columns field exists, the surplus values are placed under csv_extra_columns using existing collision resolution.
  • Adds unit regression test test_row_mode_ragged_row_with_real_extra_columns_column.
  • Adds reno release note.

How did I test it?

  • Added unit test in test/components/converters/test_csv_to_document.py.
  • Ran pytest (18 passed), reno lint, and ruff check / ruff format (all passed).

Checklist

  • I have read the contributors guidelines and code of conduct.
  • I have updated the related issue with new insights and changes.
  • I have added unit tests and updated docstrings.
  • I've used conventional commit title: fix:.
  • I have documented my code.
  • I have added a release note file.
  • I have run pre-commit hooks / ruff.

CSVToDocument in row mode previously passed restkey="extra_columns" to
csv.DictReader. When a CSV file had an actual header column named "extra_columns",
a ragged row with surplus columns wrote overflow values into row["extra_columns"],
silently discarding the real cell value.

This change:
- Uses a private sentinel (_RAGGED_ROW_RESTKEY) as csv.DictReader restkey so
  it cannot collide with any CSV header.
- Maps the sentinel to "extra_columns" during metadata merging, routing through
  existing collision resolution (prefixed as csv_extra_columns if extra_columns
  already exists in row_meta).
- Adds regression test in test_csv_to_document.py.
- Adds reno release note.

Closes deepset-ai#12994
@ansh-rohilla
ansh-rohilla requested a review from a team as a code owner September 28, 2026 12:39
@ansh-rohilla
ansh-rohilla requested review from anakin87 and removed request for a team September 28, 2026 12:39
@vercel

vercel Bot commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

@ansh-rohilla is attempting to deploy a commit to the deepset Team on Vercel.

A member of the Team first needs to authorize it.

@CLAassistant

CLAassistant commented Sep 28, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@anakin87

Copy link
Copy Markdown
Member

Thanks for the contribution but I am closing this PR.

See #12994 (comment)

@anakin87 anakin87 closed this Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CSVToDocument row mode drops a real extra_columns field on ragged rows

3 participants