fix(util): convert numpy scalars in value_to_sql#3522
Merged
wjones127 merged 1 commit intoJun 9, 2026
Conversation
table.update() crashed with NotImplementedError when an update value was a numpy scalar (e.g. np.int64, np.float32, np.bool_) such as one pulled from an ndarray or a pandas integer column. np.float64 worked only because it subclasses Python float, making the failure surprising and inconsistent. Register np.integer, np.floating, and np.bool_ handlers that delegate to the existing native-type handlers.
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's broken
Table.update(values={...})raisesNotImplementedError: SQL conversion is not implemented for this typewhen a value is a numpy scalar such asnp.int64,np.int32,np.float32, ornp.bool_. These arise naturally from indexing an ndarray or a pandas int/bool column.np.float64happens to work (it subclassesfloat), which makes the failure inconsistent and surprising.Why it happens
value_to_sqlis asingledispatchwith handlers only for native Python types andnp.ndarray; numpyinteger/floating/bool_scalars aren't Python subclasses, so they fall through to theNotImplementedErrorbase.Fix
Register handlers for
np.bool_,np.integer, andnp.floatingthat delegate to the existing native handlers.Test
value_to_sqlonnp.int32/int64/float32/float64/bool_all convert;np.int32raised before.