Skip to content

Fix numeric conversion logic#332

Merged
evertlammerts merged 4 commits intoduckdb:v1.5-variegatafrom
evertlammerts:fix_330_171_115
Feb 19, 2026
Merged

Fix numeric conversion logic#332
evertlammerts merged 4 commits intoduckdb:v1.5-variegatafrom
evertlammerts:fix_330_171_115

Conversation

@evertlammerts
Copy link
Collaborator

@evertlammerts evertlammerts commented Feb 19, 2026

Fixes #115 , #171 and #330

Copy link

@matthijskooijman matthijskooijman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for picking this up!

I had a quick glance, looks ok to me (but I am not too familiar with the code). Interesting approach to shift the python int to access the upper 64 bits :-)

I do wonder if the entire numeric parsing code could not be simplified (e.g. the lower 64-bit parsing code for hugeint is pretty similar to the parsing for bigint and other integer types, I wonder if would not make sense to just have a single bit of code that tries longlong first, then unsigned long long and if that still overflows, does the shift for the upper 64 bits (and/or maybe even just parse as huge int always and then cast down to whatever type is expected, but that is probably wrong if no explicit target type is given).

@evertlammerts
Copy link
Collaborator Author

I had a quick glance, looks ok to me (but I am not too familiar with the code). Interesting approach to shift the python int to access the upper 64 bits :-)

One of the hidden gems in Python's C API. It's better than going through an intermediate string.

I do wonder if the entire numeric parsing code could not be simplified (e.g. the lower 64-bit parsing code for hugeint is pretty similar to the parsing for bigint and other integer types, I wonder if would not make sense to just have a single bit of code that tries longlong first, then unsigned long long and if that still overflows, does the shift for the upper 64 bits (and/or maybe even just parse as huge int always and then cast down to whatever type is expected, but that is probably wrong if no explicit target type is given).

Good point. There's a lot of cleanup we could be doing, but we should at least avoid adding to the mess. I've removed some dead code and simplified some paths.

@evertlammerts evertlammerts merged commit 58e68f6 into duckdb:v1.5-variegata Feb 19, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments