Repository navigation
fix(contract): refuse floating-point columns as upsert primary keys - #82
Merged
Merged
Conversation
A `DOUBLE PRECISION` primary-key column is unsafe: IEEE-754 treats `0.0` and `-0.0` as equal, and the warehouse collapses them to one key, so `ensure_unique_key` would reject such rows mid-run. `DOUBLE_PRECISION` is the only approximate type in the contract grammar (NUMERIC is exact decimal128), so refusing it at validation moves that failure out of the write path and keeps an unwritable upsert out of the contract. Signed-off-by: Simone Carolini <simonecarolini.sc@gmail.com> Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137E9XmyUXhwPTRrtNfivDw
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.
What
Refuse a
DOUBLE PRECISIONcolumn as anupsertprimary_key, at contractvalidation time.
Why
IEEE-754 treats
0.0and-0.0as equal and the warehouse collapses them toa single key, so a float key makes
ensure_unique_keyreject rows mid-run.DOUBLE_PRECISIONis the only approximate type in the contract grammar(
NUMERICis exactdecimal128and remains a valid key), so this guard istype-precise: it moves an unwritable upsert's failure out of the write path
and keeps it out of the contract entirely.
Changes
continuo_python_runtime/contract/loader.py:_validate_primary_keyrejectsa key column whose parsed base is
DOUBLE_PRECISION, with a clearContractError.tests/contract/test_loader.py:test_primary_key_column_cannot_be_floating_point.CHANGELOG.md: extend theprimary_keybullet.Ships in 0.9.0 alongside the upsert write modes it protects.
🤖 Generated with Claude Code
https://claude.ai/code/session_0137E9XmyUXhwPTRrtNfivDw