Skip to content

Index zero and False values in the tabular pipeline - #1207

Merged
davidmezzetti merged 1 commit into
neuml:masterfrom
devYRPauli:fix/tabular-drops-zero-values
Aug 27, 2026
Merged

davidmezzetti merged 1 commit into
neuml:masterfrom
devYRPauli:fix/tabular-drops-zero-values

Conversation

@devYRPauli

Copy link
Copy Markdown
Contributor

Problem

Tabular.concat() builds the text that gets indexed for each row. It tested every column value for truthiness:

column = self.column(row[column])
if column:
    parts.append(str(column))

column() normalizes NaN to None and returns everything else unchanged, so None is the marker for a missing value. The truthy test also drops 0, 0.0 and False, which are real data.

A row of {"id": 1, "quantity": 0, "text": "Widget"} with Tabular("id", ["quantity", "text"]) indexes as "Widget". The quantity is gone, and nothing reports it.

Measured on current master:

quantity indexed text
0 "Widget"
0.0 "Widget"
False "Widget"
5 "5. Widget"

Change

concat() now compares against the marker column() actually produces:

if column is not None and column != "":

Empty strings stay excluded on purpose. Including them adds a ". " separator and no content, so {"quantity": "", "text": "Widget"} would index as ". Widget".

After the change:

quantity indexed text
0 "0. Widget"
0.0 "0.0. Widget"
False "False. Widget"
"" "Widget"
NaN "Widget"

Tests

Two tests added to test/python/testpipeline/testdata/testtabular.py:

  • testFalsyValues asserts 0 and False reach the indexed text
  • testNullValues asserts NaN and empty strings are still skipped

Reverting the one-line change makes testFalsyValues fail while testNullValues still passes, so the new test covers the behaviour that changed and not the behaviour that did not.

testtabular.py reports 8 passed. testCSV fails in my environment because it wants /tmp/txtai/tabular.csv, and it fails the same way on an unmodified checkout.

black --check reports both files unchanged.

concat() tested each column value for truthiness, so a legitimate 0, 0.0 or
False was skipped and never reached the indexed text. A row of
{"quantity": 0, "name": "Widget"} indexed as "Widget" and lost the quantity.

column() already normalizes NaN to None, so None is the marker for a missing
value. concat() now checks against that marker instead. Empty strings stay
excluded because they add a separator and no content.
@davidmezzetti davidmezzetti added this to the v9.13.0 milestone Aug 27, 2026
@davidmezzetti davidmezzetti added the bug Something isn't working label Aug 27, 2026
@davidmezzetti

Copy link
Copy Markdown
Member

LGTM - Thank you!

@davidmezzetti
davidmezzetti merged commit 27542ca into neuml:master Aug 27, 2026
4 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants