Conversation
`XLSXToDocument` wrote the string `nan` into an empty cell when
`table_format="markdown"`, while `table_format="csv"` wrote the same cell as
an empty field. The repo's own fixture sheet named "Table Missing Value"
carried both renderings, and the test pinned the inconsistency.
tabulate's `missingval` only covers `None`: a NaN reaches its formatter as a
number and is written out as `nan`. Replace the empty cells with `None` before
rendering, and default `missingval` to the empty string, so an empty cell reads
as empty and `table_format_kwargs={"missingval": "N/A"}` works as documented.
|
@L4XB is attempting to deploy a commit to the deepset Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
|
Hi @L4XB, thanks for your interest in contributing to Haystack! 🙏 This is an automated message to help us keep the review queue healthy. |
Author
|
recheck |
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why:
XLSXToDocumentrenders the same empty cell two different ways depending ontable_format:The CSV format writes an empty field. The markdown format writes the string
nan, which reads as content — a retriever indexes it, and an LLM asked what is in that cell answersnan.This is not hypothetical in this repo: the fixture sheet is literally called "Table Missing Value", and
test_run_markdownpinned thenan:The documented escape hatch does not work either.
table_format_kwargsis passed toto_markdown, and tabulate does have amissingvaloption, but it only applies toNone: a NaN reaches tabulate's formatter as a number and is written out asnan, sotable_format_kwargs={"missingval": "N/A"}changes nothing today.What:
Nonebefore rendering (value.astype(object).where(value.notna(), None)), so tabulate sees a missing value rather than a float.missingvalto""in the resolved kwargs, so an empty cell reads as empty — the same as the CSV format.table_format_kwargsstill wins, so{"missingval": "N/A"}now does what the docstring says.Only the markdown branch is touched; the CSV branch, the hyperlink handling and the metadata are unchanged.
Tests:
test_run_markdown— the pinned expectation moves fromnanto an empty cell. That assertion is the regression: onmainthe new expectation fails withtest_run_markdown_missing_value(new) —table_format_kwargs={"missingval": "N/A"}reaches tabulate. It fails onmaintoo, because the option had no effect there.The other 15 pass unchanged on both sides, including every CSV-format test.
ruff checkandruff format --checkare clean on both files. A release note is included.