Skip to content

change json vector reader to do direct fuse#6789

Merged
mccanne merged 2 commits intomainfrom
json-typedefs
Apr 2, 2026
Merged

change json vector reader to do direct fuse#6789
mccanne merged 2 commits intomainfrom
json-typedefs

Conversation

@mccanne
Copy link
Copy Markdown
Collaborator

@mccanne mccanne commented Apr 2, 2026

This commit changes the json vector reader to create an fused output with fusion types directly instead of using unblend to create a Dynamic. These changes get at the fundamental bottleneck of computing types over the variant/json pattern.

To implement this, we added a couple methods to TypeDefs to be able to enter array and record types directly without having to have a corresponding super.Type. We also created TypeDefsMapper to efficiently create super.Types from a TypeDefs table and cache intermediary types. This is used by the loader on the vector.Fusion that is created by the JSON reader to create the subtype super.Types on demand when needed.

In particular, the CSUP writer currently invokes the loader to create the super.Types then converts them to typevals that are stored in the subtypes table in the CSUP metadata. The next step to improve this write path is the store the TypeDefs in the CSUP metadata instead of type values and never materialize the subtype IDs to types if they are never otherwise needed. This means large amounts of JSON can be read, processed, and written into CSUP and the query type context does not need to be polluted with all the fusion subtypes.

We also put an option into samFunc call to avoid ripping vectors when fusion vectors are passed to defuse.

Finally we increased the size of fjson batch size from 1K to 10K.

mccanne added 2 commits April 1, 2026 19:15
This commit changes the json vector reader to create an fused output
with fusion types directly instead of using unblend to create a Dynamic.
These changes get at the fundamental bottleneck of computing types over
the variant/json pattern.

To implement this, we added a couple methods to TypeDefs to be able
to enter array and record types directly without having to have
a corresponding super.Type.  We also created TypeDefsMapper to efficiently
create super.Types from a TypeDefs table and cache intermediary types.
This is used by the loader on the vector.Fusion that is created by the
JSON reader to create the subtype super.Types on demand when needed.

In particular, the CSUP writer currently invokes the loader to create
the super.Types then converts them to typevals that are stored in the
subtypes table in the CSUP metadata.  The next step to improve this
write path is the store the TypeDefs in the CSUP metadata instead of
type values and never materialize the subtype IDs to types if they
are never otherwise needed.  This means large amounts of JSON can
be read, processed, and written into CSUP and the query type context
does not need to be polluted with all the fusion subtypes.

We also put an option into samFunc call to avoid ripping vectors
when fusion vectors are passed to defuse.

Finally we increased the size of fjson batch size from 1K to 10K.
)

var VecBatchSize uint32 = 1024
var VecBatchSize uint32 = 10 * 1024
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this based on measurement or intuition? If intuition, consider that DuckDB's default is 2048.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Let's merge and address again after measurement.

Comment on lines +215 to +217
if call.Tag == "defuse" {
callExpr.NoRip = true
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is fine for now but we do have an existing pattern for per-function behaviors like this (see the RipUnions interface).

@mccanne mccanne merged commit 32b1b0d into main Apr 2, 2026
2 checks passed
@mccanne mccanne deleted the json-typedefs branch April 2, 2026 16:24
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