Repository navigation
Index zero and False values in the tabular pipeline - #1207
Merged
davidmezzetti merged 1 commit intoAug 27, 2026
Merged
Conversation
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.
Member
|
LGTM - Thank you! |
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.
Problem
Tabular.concat()builds the text that gets indexed for each row. It tested every column value for truthiness:column()normalizes NaN toNoneand returns everything else unchanged, soNoneis the marker for a missing value. The truthy test also drops0,0.0andFalse, which are real data.A row of
{"id": 1, "quantity": 0, "text": "Widget"}withTabular("id", ["quantity", "text"])indexes as"Widget". The quantity is gone, and nothing reports it.Measured on current master:
0"Widget"0.0"Widget"False"Widget"5"5. Widget"Change
concat()now compares against the markercolumn()actually produces: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:
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:testFalsyValuesasserts0andFalsereach the indexed texttestNullValuesasserts NaN and empty strings are still skippedReverting the one-line change makes
testFalsyValuesfail whiletestNullValuesstill passes, so the new test covers the behaviour that changed and not the behaviour that did not.testtabular.pyreports 8 passed.testCSVfails in my environment because it wants/tmp/txtai/tabular.csv, and it fails the same way on an unmodified checkout.black --checkreports both files unchanged.