Repository navigation
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Contributor
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.
Impact
Filtering a PGVectorStore on string metadata that merely looks numeric to Python, e.g. file_name="2024_123", crashes the query with DataError: invalid input syntax for type double precision instead of matching the document. Any metadata with underscores between digits (dates, IDs, filenames) makes metadata filtering unusable. This fixes #15962.
Cause
build_filter_clause probes float(value) to decide between the ::float and text SQL branches. Python's float() accepts underscores (float("2024_123") is 2024123.0), so the probe succeeds and emits (metadata->>'file_name')::float = 2024123.0, which Postgres rejects because the stored string is not a valid float literal. The except ValueError text fallback never fires.
Fix
Route string values containing _ to the existing text-comparison branch. Behavior is unchanged for every other input: genuine numeric strings ("3.14", "1e5") and real ints/floats still take the ::float path, and non-numeric strings still take the text path.
Fixes #15962.