fix(plugin-duckdb): render GEOMETRY as WKT and 9 other fixes (#1324)#1329
Merged
Conversation
This was referenced May 28, 2026
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
GEOMETRYcolumns now render as WKT (POINT (...),POLYGON (...)) instead of NULL in both the data grid and streaming results. Done by detectingDUCKDB_TYPE_GEOMETRYand extending the existingpatchTzColumnsquery-rewrite to wrap geometry columns withST_AsText(...); the streaming path now detects unrenderable types upfront and routes through a wrapped query.HUGEINT/UHUGEINTformatting. Extracted to a newHugeIntFormatterthat does two's-complement and lossless 4-limb decimal conversion for the full 128-bit range. The previous codeUInt64(negativeInt64)force-trapped on negative HUGEINT values andDecimaloverflowed past ~5.4×10⁹ for UHUGEINT.streamQueryresource lifecycle: addeddefer { duckdb_destroy_result }, row cap fromPluginRowLimits.emergencyMax, warning on truncation. Streaming path now also picks up TZ and GEOMETRY columns that previously rendered as NULL.allTablesMetadataSQL: schema name is now single-quote-escaped._currentSchema:generateCreateTableSQLandqualifiedTableNamenow route through the locked accessor.enum_rangemissing schema qualifier: broke ENUMs outsidemain; nowenum_range(NULL::"schema"."type").patchTzColumnssemicolon strip operated on un-trimmed string: now strips from the trimmed version.DATE/TIMESTAMPBC year formatting:-44rendered as-044, now-0044(canonical ISO).duckdb_free(&mutableBlob.data)with directduckdb_free(blob.data).patchTzColumns→ unified mechanism (_tp_castalias) that handles both TZ and GEOMETRY.Verified end-to-end with the repro from the issue:
INSTALL spatial; LOAD spatial; CREATE TABLE places (id INT, name VARCHAR, location GEOMETRY); INSERT ... ST_Point/ST_GeomFromText; SELECT *—locationcolumn now shows WKT (POINT (0 0),POLYGON ((...))) instead of NULL.Out of scope (proposed follow-up)
The deeper audit surfaced ~20 more bugs that all stem from the legacy
duckdb_value_*API the plugin builds on. A proper fix is a full rewrite onto DuckDB's chunk API (duckdb_fetch_chunk/duckdb_data_chunk_get_vector/duckdb_vector_get_validity/ logical-type dispatch). That would eliminateextractFallbackValueandpatchTzColumnsentirely, add a client-sideWKBDecoderso we drop theST_AsTextSQL rewrite, and bring native support forINTERVAL,BIGNUM,BIT,ENUMdictionaries,LIST/ARRAY/STRUCT/MAP/UNION, nativeTIMESTAMP_NS/TIME_NSprecision, andDECIMALwidth/scale. Tracking that as a follow-up to keep this PR reviewable.Test plan
SELECT now()::TIMESTAMPTZ AS ts, now()::TIMETZ AS tviastreamQuery(data tab streaming path) — TZ values render correctly.SELECT (-170141183460469231731687303715884105728)::HUGEINT— value renders, no crash.SELECT (170141183460469231731687303715884105727)::HUGEINT— full precision.SELECT '999999999999999999999999999999999'::UHUGEINT— full precision, not scientific notation.CREATE SCHEMA "it's";) and list tables — no error.