Reject malformed vector column types with exact-match parsing#310
Open
stumpylog wants to merge 1 commit into
Open
Reject malformed vector column types with exact-match parsing#310stumpylog wants to merge 1 commit into
stumpylog wants to merge 1 commit into
Conversation
The vec0 column-type parser matched element type names with a prefix-only `sqlite3_strnicmp` (e.g. comparing the first 5 bytes against "float"). Any identifier sharing a prefix with a real type was silently coerced to that type: `float16[768]` became a 32-bit `float` column, `bitcoin[2]` became `bit`, and typos like `floaty` were accepted instead of erroring. Compare the full identifier length so only exact element-type spellings parse. `float32` is added as an explicit alias since it was previously accepted via the `float` prefix and is a natural spelling to keep working. This also unblocks adding real `float16`/`bfloat16` types (asg017#27), which would otherwise collide with the `float` prefix. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
The vec0 column-type parser matched element type names with a prefix-only
sqlite3_strnicmp(comparing only the first N bytes against"float","int8","bit", etc.). Any identifier sharing a prefix with a real type was silently coerced to that type:float16[768]→ a 32-bitfloatcolumn (silently, double the intended storage)bitcoin[2]→ abitcolumnfloaty[2]→ accepted instead of rejectedThis compares the full identifier length so only exact element-type spellings parse.
float32is added as an explicit alias, since it was previously accepted via thefloatprefix and is a natural spelling to keep working.This also unblocks adding real
float16/bfloat16types (#27), which would otherwise collide with thefloatprefix.Testing
tests/test-column-type-parse.pyasserts valid spellings (float,f32,float32,int8,i8,bit) are accepted and lookalikes (float16,bitcoin,floaty, ...) are rejected.test-loadable.pythat incidentally used the bogusfloat8[1]were corrected tofloat[1].