Add VARIANT appender shredding test#161
Open
wmTJc9IK0Q wants to merge 1 commit into
Open
Conversation
Adds TestQueryAppenderVariantShredding, which appends semi-structured key-value data with runtime-determined keys into a VARIANT column via NewQueryAppender (temp VARCHAR column cast col2::JSON::VARIANT), then proves the storage engine shreds it. The direct data-chunk appender and prepared binds reject VARIANT (no Go vector setter, no C-API to construct a variant), so the query appender is the working path. The test is an A/B on an on-disk STORAGE_VERSION v1.5.0 database: identical rows are appended into two tables differing only by variant_minimum_shredding_size (-1 vs 0) at CHECKPOINT time. Shredding is observed via pragma_storage_info (typed value segments present only when shredded) and confirmed field-addressable (variant_typeof OBJECT(x, y), col.x round-trip).
taniabogatsch
approved these changes
Jul 23, 2026
taniabogatsch
left a comment
Member
There was a problem hiding this comment.
Thanks, looks good to me! Could you just have a look at the failing linter?
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
Adds
TestQueryAppenderVariantShredding(appender_test.go), a test that bulk-insertssemi-structured key-value data with keys not known at compile time into a
VARIANTcolumn through the appender API, and proves the DuckDB storage engineshreds the values.
Why
The direct data-chunk appender and prepared-statement binds both reject
VARIANT(
TestAppenderRejectsVariant,appender.go,statement.go): Go vector setters can'temit
VARIANTand there's no C-API helper to construct a variant. This test documentsand locks in the one path that does work and verifies it end to end, including the storage-level shredding behavior introduced in DuckDB 1.5.
How it works
NewQueryAppenderwith a temp table holding anINTEGERid and aVARCHARJSON document; the INSERT castscol2::JSON::VARIANT, producing a properOBJECT(x, y)variant. Keys come from runtime data (map[string]any→json.Marshal),not a compile-time struct, so arbitrary/unknown keys are supported.
STORAGE_VERSION 'v1.5.0', identical rows are appended into two tables that differ onlyby
variant_minimum_shredding_size(-1disabled vs0forced) at their respectiveCHECKPOINT— the setting is GLOBAL and consulted at checkpoint time.pragma_storage_infothen shows typed value segments present only in the shreddedtable (zero in the unshredded baseline), which is direct storage-engine evidence.
variant_typeof(col) = OBJECT(x, y)andcol.x/col.yextractthe original values.
Notes
jsonextension bundled with the duckdb-go bindings (already used byexamples/jsonandTestJSON); aSELECT '{}'::JSONwarmup loads it before theappender INSERT.
that is provably absent without shredding, giving an unambiguous signal.