Conversation
cpruijsen
force-pushed
the
fix/issue-397
branch
2 times, most recently
from
September 18, 2026 19:23
de9ed62 to
e402bb7
Compare
Quote categorical values for pandas.query based on the value type so string categories are not treated as variable names.
cpruijsen
force-pushed
the
fix/issue-397
branch
from
September 20, 2026 12:51
e402bb7 to
99d83a4
Compare
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.
Quote string categorical values in
NewRowSynthesisquery filters withrepr(value).Resolves #397.
NewRowSynthesisbuiltDataFrame.queryfilters by checkingreal_data[field].dtype == 'O'. Pandascategoryandstringdtypesare not
'O', so a string value such asFwas interpolated unquotedand pandas treated it as a variable name (
UndefinedVariableError).The same metric is what
DiagnosticReportuses for the Synthesisproperty.
Decision
Quote with
repr(value)when the categorical value is astr,otherwise interpolate the raw value. Closed PR #458 always used
repr(row[field]).iterrows()yields numpy scalars for integer andboolean categoricals, and on current numpy
repr(np.int64(1))isnp.int64(1), which pandas.query cannot parse, whilef'{np.int64(1)}'is1. Can switch to always-reprafter.item(),or to passing values through
local_dict.Test plan
test_compute_breakdown_with_category_dtypefails on main withUndefinedVariableError: name 'F' is not definedand passes heretest_compute_breakdown_with_string_dtypelikewisetests/unit/single_table/test_new_row_synthesis.pystillpass (integer categoricals and multi-line strings)