fix: Serialize VARINT/BIGNUM, GEOMETRY and VARIANT columns (#89)#93
Merged
Conversation
These types previously fell through to the default case and serialized as null. Replace that with a universal C++-API fallback: a duckdb_vector handle is a reinterpret_cast of duckdb::Vector*, so we borrow the C++ Vector and use DuckDB's own Value stringification. - VARINT/BIGNUM -> exact decimal string (lossless arbitrary precision). - GEOMETRY -> DuckDB's text form, e.g. 'POINT (1 2)' (spatial loaded). - VARIANT -> embedded as nested JSON when its rendering is JSON, otherwise its string form. - default/unknown/future types -> best-effort string instead of null. Wrapped in try/catch so an unconvertible extension value degrades to null rather than crashing. Adds [exotic_types] regression tests for VARINT (incl. negative/large/multi-row) and VARIANT (object, scalar, struct-origin, NULL). Found via the type audit on #89.
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.
Summary
Closes the last gap from the #89 type audit.
VARINT/BIGNUM,GEOMETRY, andVARIANTpreviously fell through to the default case and serialized asnull. They now produce real values.Instead of hand-writing a decoder per type, this uses a universal C++-API fallback: a C-API
duckdb_vectorhandle is just areinterpret_castofduckdb::Vector*, so we borrow the C++Vectorand let DuckDB's ownValuestringification do the work.VARINT/BIGNUMnullGEOMETRYnull"POINT (1 2)"(spatial loaded)VARIANTnullnullThe whole fallback is wrapped in
try/catch, so an unconvertible extension value degrades tonullrather than crashing.Notes
HUGEINTdecision in fix: Correct REST JSON serialization of UUID/HUGEINT/BLOB/BIT (#89) #92) so values beyond 2⁵³ survive JSON consumers.VARIANTstringifies as DuckDB's SQL-ish{'k': v}(not JSON), so it serializes as a string; JSON-derivedVARIANTs embed as nested JSON. Documented in code + tests.Test plan
[query_executor][exotic_types]tests: VARINT (negative/large/multi-row/NULL), VARIANT (object embed, scalar, struct-origin, NULL).GEOMETRYverified manually (POINT (1 2)); not in committed tests since it needs the spatial extension download.Relates to #89