Catalogs
On this page
Exposing schemas, tables, and views to ATTACH.
struct AttachCatalogInfo
Section titled âstruct AttachCatalogInfoâtype AttachCatalogInfo struct {// Alias is the ATTACH alias; also the SourceCatalog a catalog-table// ScanBranch references. Namespace it by your catalog identity so two workers// don't both claim the same name (collisions are rejected, never merged).Alias string// Target is the ATTACH target â a path or DSN, e.g.// "ducklake:sqlite:/data/meta.sqlite" or "postgres:dbname=... host=...".Target string// DBType is the DuckDB db type (e.g. "ducklake", "postgres"). Empty => the// extension infers it from the Target scheme prefix.DBType string// Options are extra ATTACH options forwarded verbatim (e.g. DuckLake DATA_PATH).Options map[string]string// Hidden attaches the companion excluded from duckdb_databases() (still// resolvable by qualified name and by branches).Hidden bool// Required: when true, a failure to attach fails the whole VGI ATTACH; when// false it is logged and skipped.Required bool// SecretRef optionally names a credential to inject into the companion's// ATTACH options (opt-in on the client via attach_companion_secrets).SecretRef string}Description
AttachCatalogInfo is a companion catalog the client should ATTACH when this VGI catalog attaches (lakehouse federation). It is IPC-serialized into CatalogAttachResult.attach_catalogs; the C++ VGI extension attaches each entry at VGI-attach time so multi-branch catalog-table branches (and direct queries) can resolve tables in a companion DuckLake / Iceberg / Postgres / DuckDB.
struct AttachOptionSpec
Section titled âstruct AttachOptionSpecâtype AttachOptionSpec struct {Name stringDescription stringType arrow.DataTypeDefaultBatch arrow.RecordBatchRequired bool}Description
AttachOptionSpec describes an ATTACH-time option the worker accepts. Mirrors vgi-pythonâs AttachOptionSpec: wire format is the same as SettingSpec so DuckDB can parse both with shared code.
DefaultBatch, when non-nil, must be a single-row RecordBatch whose only column (name âvalueâ) has type Type. Use this to carry defaults for types like list/struct/decimal/date/time/timestamp that are awkward to express as Go scalars. Callers that only need primitive defaults can use BuildDefaultValueBatch.
Required marks an option the caller must supply at ATTACH time. A catalog that cannot be attached without it advertises that at discovery, so a client can say so before attempting the attach rather than surfacing a failure that reads like an empty catalog. It is mutually exclusive with a default: an option that falls back to a value is by definition satisfiable without the caller.
struct CatalogDataVersionRelease
Section titled âstruct CatalogDataVersionReleaseâtype CatalogDataVersionRelease struct {// Version is the concrete published version (e.g. "1.0.0"), not a spec.Version string// ReleasedAt is the release date (UTC). Nil when the worker doesn't track// dates.ReleasedAt *time.Time// Summary is a one-line human summary; empty string when unknown.Summary string// NotesURL optionally links to detailed notes for this release.NotesURL *string}Description
CatalogDataVersionRelease is one published data version of a catalog. It mirrors vgi-pythonâs CatalogDataVersionRelease. Entries on CatalogInfo.Releases must be newest-first and unique by Version.
struct CatalogExample
Section titled âstruct CatalogExampleâtype CatalogExample struct {SQL stringDescription stringExpectedOutput *string}Description
CatalogExample is a usage example attached to a FunctionInfo.
struct CatalogInfo
Section titled âstruct CatalogInfoâtype CatalogInfo struct {Name stringImplementationVersion *stringDataVersionSpec *string// AttachOptionSpecs holds pre-serialized AttachOptionSpec records (one per// declared ATTACH-time option). Surfaced to DuckDB via vgi_catalogs() so// the extension can validate ATTACH options before attach.AttachOptionSpecs [][]byte// Releases lists the concrete published data versions, newest-first. Empty// when the worker doesn't track release history.Releases []CatalogDataVersionRelease// SourceURL points at where this worker's code lives (repo, build, docs).// Nil when the worker doesn't advertise a source location.SourceURL *string}Description
CatalogInfo is the discovery record returned by catalog_catalogs.
struct CatalogMacro
Section titled âstruct CatalogMacroâtype CatalogMacro struct {// Name is the macro name visible in SQL.Name string// MacroType is "scalar" or "table".MacroType MacroType// Parameters lists the parameter names in order.Parameters []string// ParameterDefaultValues is the serialized Arrow IPC bytes of a 1-row// RecordBatch containing default values (nil when no defaults).ParameterDefaultValues []byte// Definition is the SQL expression (scalar) or query (table).Definition string// Comment is a human-readable description.Comment string// Tags are arbitrary key/value annotations attached to this macro;// surfaced through MacroInfo.tags.Tags map[string]string// ParameterDocs is an optional mapping of parameter name to a// human/agent-facing description. Keys must appear in Parameters.// Descriptions flow over the wire via the macro arguments_schema's// vgi_doc field metadata (the same channel functions use for per-argument// docs). Empty/nil means no per-parameter docs.ParameterDocs map[string]string}Description
CatalogMacro describes a macro to register in the catalog.
struct CatalogTable
Section titled âstruct CatalogTableâtype CatalogTable struct {// Name is the table name visible in SQL.Name string// Comment is a human-readable description.Comment string// Columns is the explicit column schema. If nil and Function is set,// columns are derived from the function's OnBind response.Columns *arrow.Schema// Function is the backing table function (nil for handler-only tables).Function TableFunction// FuncArgs are the arguments to pass when calling the backing function.FuncArgs []CatalogTableArg// NotNull lists column names with NOT NULL constraints.NotNull []string// Unique lists groups of column names for UNIQUE constraints.Unique [][]string// Check lists check constraint expressions.Check []string// PrimaryKey lists groups of column names for PRIMARY KEY constraints.PrimaryKey [][]string// ForeignKey lists foreign key definitions.ForeignKey []ForeignKeyConstraint// Defaults maps column names to their default values.// Supported types: Sql (raw SQL), string, int/int64/int32, float64/float32, bool, nil.Defaults map[string]any// ColumnComments maps column names to per-column comments surfaced// through duckdb_columns().comment.ColumnComments map[string]string// Generated maps column names to SQL expressions for generated (virtual)// columns. Encoded as `generated_expression` Arrow field metadata.Generated map[string]string// Statistics holds optimizer hints per column name. When non-empty,// the catalog reports supports_column_statistics=true for this table and// answers catalog_table_column_statistics_get from this map.Statistics map[string]*ColumnStatistics// StatisticsCacheMaxAgeSeconds, when set, is emitted as// cache_max_age_seconds schema metadata on the stats batch.// Nil means cache indefinitely; 0 means do not cache.StatisticsCacheMaxAgeSeconds *int64// SupportsTimeTravel indicates this table supports AT (VERSION/TIMESTAMP) queries.SupportsTimeTravel bool// CardinalityEstimate, when non-nil, inlines the table's row-count estimate// on TableInfo. The C++ extension uses it directly and skips the per-bind// table_function_cardinality RPC. Use only for read-only / slow-changing// tables where cardinality is statically known.CardinalityEstimate *int64// CardinalityMax mirrors CardinalityEstimate for the cardinality upper bound.CardinalityMax *int64// Tags are arbitrary key/value annotations attached to this table.// They surface to DuckDB on TableInfo.tags and are visible through// duckdb_tables().tags. Useful for category/coverage/example_queries// metadata.Tags map[string]string// RequiredFilters is the required WHERE-filter set in conjunctive normal// form (CNF): an AND (outer list) of OR-groups (inner lists) of dotted-path// column references. A group is satisfied when any one of its member paths// has a WHERE filter; every group must be satisfied. So// [][]string{{"accession_number"}, {"ticker", "cik"}} means// "accession_number AND one of (ticker, cik)"; a singleton group// [][]string{{"country"}} is a plain mandatory filter. Paths are top-level// names ("country") or struct subfields ("bbox.xmin", "nested.outer.inner").// Empty (default) means no enforcement â the zero-cost fast path. The VGI// DuckDB extension's optimizer pass enforces this at bind time and throws// BinderException listing any unsatisfied groups; satisfaction is// prefix-based (a filter on a parent path satisfies its child paths).RequiredFilters [][]string// InlineBind, when true and the table's columns are statically known,// inlines the bind result onto TableInfo.bind_result so the C++ extension// skips the per-scan bind RPC. Safe only for tables whose output schema is// static (the resolved Columns schema is authoritative for every scan).InlineBind bool}Description
CatalogTable describes a table to register in the catalog.
struct CatalogTableArg
Section titled âstruct CatalogTableArgâtype CatalogTableArg struct {// Position is the 0-based positional index, or -1 for named arguments.Position int// Name is the argument name (for named args).Name string// Value is the Go value (int64, float64, string, bool, []byte).Value interface{}// Type is the Arrow type for serialization.Type arrow.DataType}Description
CatalogTableArg describes a single argument for a function-backed table.
struct CatalogView
Section titled âstruct CatalogViewâtype CatalogView struct {// Name is the view name visible in SQL.Name string// Definition is the SQL query backing the view.Definition string// Comment is a human-readable description.Comment string// Tags are arbitrary key/value annotations attached to this view;// surfaced through ViewInfo.tags.Tags map[string]string// ColumnComments maps output column names to per-column comments. The// C++ extension aligns these by name against the columns DuckDB binds// from the view definition and surfaces them via duckdb_columns().comment.ColumnComments map[string]string}Description
CatalogView describes a view to register in the catalog.
struct ColumnStatistics
Section titled âstruct ColumnStatisticsâtype ColumnStatistics struct {ColumnName stringType arrow.DataType // Arrow type of Min/Max (required if either is set)Min interface{} // e.g. int64(1), float64(0.99), "Accounting", nilMax interface{}HasNull boolHasNotNull boolDistinctCount int64 // 0 treated as unknown// ContainsUnicode and MaxStringLength apply only to string/binary columns.ContainsUnicode *boolMaxStringLength *int64distinctCountSet bool // zero-value disambiguator}Description
ColumnStatistics describes optimizer hints for one column. Match the Python ColumnStatistics dataclass in vgi-python/vgi/catalog/catalog_interface.py.
Min/Max are stored as Go scalars; SerializeColumnStatistics handles the Arrow sparse-union encoding the wire protocol expects.
Methods
method SetDistinctCount
Section titled âmethod SetDistinctCountâfunc (c *ColumnStatistics) SetDistinctCount(n int64)SetDistinctCount sets the distinct-count estimator (including 0 as a valid value).
struct DefaultReadOnlyCatalog
Section titled âstruct DefaultReadOnlyCatalogâtype DefaultReadOnlyCatalog struct {catalogName stringschemas map[string]*catalogSchemaInfoversion int64attachOpaqueData []byte}Description
DefaultReadOnlyCatalog auto-generates from registered functions.
Methods
function NewDefaultReadOnlyCatalog
Section titled âfunction NewDefaultReadOnlyCatalogâfunc NewDefaultReadOnlyCatalog(catalogName string, w *Worker) *DefaultReadOnlyCatalogNewDefaultReadOnlyCatalog creates a catalog from registered functions.
struct ForeignKeyConstraint
Section titled âstruct ForeignKeyConstraintâtype ForeignKeyConstraint struct {// Columns are the column names in this table.Columns []string// ReferencedTable is the name of the referenced table.ReferencedTable string// ReferencedColumns are the column names in the referenced table.ReferencedColumns []string// ReferencedSchema is the schema of the referenced table (empty = same schema).ReferencedSchema string}Description
ForeignKeyConstraint describes a foreign key relationship.
struct FunctionInfo
Section titled âstruct FunctionInfoâtype FunctionInfo struct {Name stringSchemaName stringFunctionType FunctionTypeArgSchema *arrow.Schema // argument schemaOutputSchema *arrow.Schema // return schemaStability FunctionStabilityNullHandling NullHandlingDescription stringComment stringTags map[string]stringExamples []CatalogExampleCategories []stringProjectionPushdown *boolFilterPushdown *boolSamplingPushdown *boolLateMaterialization *boolSupportedExpressionFilters []stringOrderPreservation OrderPreservation // "" = nullMaxWorkers int32SupportsBatchIndex bool // opt-in per-batch batch_index taggingPartitionKind PartitionKind // default PartitionKindNotPartitionedOrderDependent OrderDependence // default NOT_ORDER_DEPENDENTDistinctDependent DistinctDependence // default NOT_DISTINCT_DEPENDENTSupportsWindow boolStreamingPartitioned boolHasFinalize bool// Table-buffering (sink/source) ordering hints. Default false.SourceOrderDependent boolSinkOrderDependent boolRequiresInputBatchIndex bool// InputFromArgs marks a blended ("UNNEST-style") table-in-out function: its// positional args ARE the per-row input columns (real typed args, no TABLE// placeholder), so one registration serves literal / column / LATERAL call// shapes. The C++ extension reads it to enter the in-out registration branch// with real-typed args and drive the literal single-row scan-mode.InputFromArgs boolRequiredSettings []stringRequiredSecrets []SecretRequirement
// catalogHome is the single catalog that owns this registration. It lives// on the entry rather than in a name-keyed map because two catalogs served// by one worker may each declare their own implementation of one name.catalogHome string// unlisted hides the entry from every function listing without changing its// home (it exists to back a catalog table).unlisted bool}Description
FunctionInfo describes a function in the catalog.
struct MacroDefault
Section titled âstruct MacroDefaultâtype MacroDefault struct {Name stringValue interface{}Type arrow.DataType}Description
MacroDefault describes a single parameter default value.
struct MacroInfo
Section titled âstruct MacroInfoâtype MacroInfo struct {Name stringSchemaName stringComment stringTags map[string]stringMacroType MacroTypeParameters []stringParameterDefaultValues []byteDefinition string// ArgumentsSchema is the optional macro arguments schema, serialized as// Arrow IPC bytes: one nullable field per parameter, in Parameters order,// each carrying its description via the vgi_doc field-metadata key (the// same channel functions use). nil when no per-parameter docs are supplied.ArgumentsSchema []byte}Description
MacroInfo describes a macro in the catalog for wire serialization.
Methods
function macroInfoFromCatalogMacro
Section titled âfunction macroInfoFromCatalogMacroâfunc macroInfoFromCatalogMacro(cm CatalogMacro, schemaName string) (*MacroInfo, error)macroInfoFromCatalogMacro builds the wire MacroInfo for a registered CatalogMacro in the given schema, including the per-parameter arguments_schema (carrying vgi_doc field metadata for documented parameters).
type MacroType
Section titled âtype MacroTypeâtype MacroType stringDescription
MacroType identifies the kind of macro.
Methods
function macroKindFilter
Section titled âfunction macroKindFilterâfunc macroKindFilter(s string) MacroTypemacroKindFilter maps a schema_contents_macros âtypeâ filter value (as sent by DuckDB) to a MacroType. Returns ââ for an unrecognized value.
struct MissingAttachOptionsError
Section titled âstruct MissingAttachOptionsErrorâtype MissingAttachOptionsError struct {CatalogName stringMissing []string}Description
MissingAttachOptionsError reports an ATTACH that omitted options declared Required. Missing carries the names so a caller can act on them without parsing the message. Mirrors Pythonâs MissingAttachOptionsError, message included â the extensionâs integration suite matches on its text.
Methods
method Error
Section titled âmethod Errorâfunc (e *MissingAttachOptionsError) Error() stringError renders the missing option names, matching the Python and Go implementationsâ message text.
struct ScanArg
Section titled âstruct ScanArgâtype ScanArg struct {Value interface{}Type arrow.DataType}Description
ScanArg is a single argument value with its Arrow type.
struct ScanBranch
Section titled âstruct ScanBranchâtype ScanBranch struct {// FunctionName is the function to call (a VGI table function or any native// DuckDB function such as read_parquet).FunctionName string// PositionalArguments / NamedArguments are passed to the function's bind.PositionalArguments []ScanArgNamedArguments map[string]ScanArg// BranchFilter, when non-nil, is a SQL expression ANDed into every scan of// this branch before filter pushdown. Used to make overlapping physical// sources non-overlapping at scan time.BranchFilter *string// Writable declares this branch as the INSERT target. At most one branch// per table may be writable (the C++ extension enforces this at parse time).Writable bool// SourceCatalog/SourceSchema/SourceTable define a *catalog-table* branch:// when FunctionName is "" and SourceTable is set, the branch scans the base// table SourceCatalog.SourceSchema.SourceTable in a companion catalog// (lakehouse federation) instead of calling a table function. Nil = function// branch.SourceCatalog *stringSourceSchema *stringSourceTable *string}Description
ScanBranch is one physical source backing a multi-branch scan. It mirrors vgi-pythonâs ScanBranch.
struct ScanBranchesResult
Section titled âstruct ScanBranchesResultâtype ScanBranchesResult struct {Branches []ScanBranch// RequiredExtensions is the union of DuckDB extensions needed across all// branches, hoisted to the top level.RequiredExtensions []string}Description
ScanBranchesResult is the list of physical sources backing a multi-branch table. The branches list must be non-empty. It mirrors vgi-pythonâs ScanBranchesResult.
func type ScanFunctionGetHandler
Section titled âfunc type ScanFunctionGetHandlerâtype ScanFunctionGetHandler func(schemaName, tableName string, atUnit, atValue *string) (*ScanFunctionResult, error)Description
ScanFunctionGetHandler is a callback for resolving table scan functions that are not backed by a registered CatalogTable with a Function field. atUnit and atValue carry time-travel AT clause parameters (both nil when absent).
struct ScanFunctionResult
Section titled âstruct ScanFunctionResultâtype ScanFunctionResult struct {// FunctionName is the name of the function to invoke.FunctionName string// PositionalArguments are the positional arguments.PositionalArguments []ScanArg// NamedArguments are the named arguments.NamedArguments map[string]ScanArg// RequiredExtensions lists DuckDB extensions that must be loaded.RequiredExtensions []string}Description
ScanFunctionResult describes the function to call when scanning a catalog table.
struct SchemaInfo
Section titled âstruct SchemaInfoâtype SchemaInfo struct {Name stringComment stringTags map[string]stringAttachOpaqueData []byte// EstimatedObjectCount, when non-nil, advertises the approximate per-kind// population (e.g. {"table": 0, "view": 12}). A value of 0 is a hard// guarantee â the C++ client skips the corresponding bulk RPC and any// per-name lookup for that kind. Nil disables the optimisation entirely.EstimatedObjectCount map[string]int64}Description
SchemaInfo describes a schema in the catalog.
type SerializedItems
Section titled âtype SerializedItemsâtype SerializedItems = [][]byteDescription
SerializedItems is a list of Arrow-IPC-encoded items sent over the wire.
type Sql
Section titled âtype Sqlâtype Sql stringDescription
Sql represents a raw SQL expression that should be passed through verbatim (e.g. current_timestamp, nextval(âseqâ)).
struct TableColumnStatisticsResult
Section titled âstruct TableColumnStatisticsResultâtype TableColumnStatisticsResult struct {Statistics []ColumnStatistics// CacheMaxAgeSeconds: nil means cache indefinitely; 0 means no cache.CacheMaxAgeSeconds *int64}Description
TableColumnStatisticsResult is the full reply to catalog_table_column_statistics_get.
func type TableGetHandler
Section titled âfunc type TableGetHandlerâtype TableGetHandler func(schemaName, tableName string, atUnit, atValue *string) ([]byte, error)Description
TableGetHandler is a callback for customizing catalog_table_get responses, e.g. to return version-specific schemas for time-travel queries. Return nil to fall through to the default table lookup.
struct TableInfo
Section titled âstruct TableInfoâtype TableInfo struct {Name stringSchemaName stringComment stringTags map[string]stringColumns *arrow.Schema // serialized as IPC schema bytesNotNullConstraints []int32UniqueConstraints [][]int32CheckConstraints []stringPrimaryKeyConstraints [][]int32ForeignKeyConstraints [][]byte // each []byte is an IPC-serialized FK RecordBatchSupportsInsert boolSupportsUpdate boolSupportsDelete boolSupportsReturning boolSupportsColumnStatistics bool
// Optional inlined function-discovery results. When populated (non-nil),// the C++ extension uses the cached bytes and skips the corresponding// catalog_table_{scan,insert,update,delete}_function_get RPC. Bytes are// the IPC payload from SerializeScanFunctionResult.ScanFunction []byteInsertFunction []byteUpdateFunction []byteDeleteFunction []byte
// Optional inlined cardinality. When set, the C++ extension uses these// directly and skips the table_function_cardinality RPC. Use nil to leave// the field unset (per-bind RPC continues to fire).CardinalityEstimate *int64CardinalityMax *int64
// Optional inlined column statistics. Bytes are the IPC payload from// SerializeColumnStatistics. When non-nil, the C++ extension skips the// per-bind catalog_table_column_statistics_get and the per-scan// table_function_statistics RPCs.ColumnStatistics []byte
// Optional inlined bind result. Bytes are the IPC payload from a bind// response. When non-nil, the C++ extension threads it straight into// bind_data and skips the per-scan bind RPC.BindResult []byte
// RequiredFilters is the required WHERE-filter set in conjunctive normal// form (CNF): an AND (outer list) of OR-groups (inner lists) of dotted-path// column references that MUST appear in a WHERE expression for any scan of// this table. A group is satisfied when any one of its member paths has a// filter; every group must be satisfied. So [["accession_number"],// ["ticker","cik"]] means "accession_number AND one of (ticker, cik)".// Paths are top-level names ("country") or struct subfields ("bbox.xmin").// Empty (default) means no enforcement. The C++ extension's optimizer pass// consults this at bind time and throws BinderException listing any// unsatisfied groups. Satisfaction is prefix-based â a filter on a parent// path satisfies every required child path.//// This is the trailing field of the TableInfo wire schema.RequiredFilters [][]string}Description
TableInfo describes a table in the catalog for wire serialization.
Methods
function tableInfoFromWritable
Section titled âfunction tableInfoFromWritableâfunc tableInfoFromWritable(t *writableTable, schemaName string) (*TableInfo, error)struct ViewInfo
Section titled âstruct ViewInfoâtype ViewInfo struct {Name stringSchemaName stringComment stringTags map[string]stringDefinition stringColumnComments map[string]string}Description
ViewInfo describes a view in the catalog for wire serialization.
struct WritableCatalog
Section titled âstruct WritableCatalogâtype WritableCatalog struct {// Name is the SQL-visible catalog name (must match ATTACH '<name>').Name string// Comment is an optional human-readable description.Comment string
mu sync.MutexattachOpaqueData []byteversion int64// schemas keyed by schema name (lower-case canonical form).schemas map[string]*writableSchema// store persists schemas/tables/rows across worker processes.store *writableStore}Description
WritableCatalog is a name-bound writable catalog hosted by a Worker. It owns a per-catalog set of schemas and tables that can be created, dropped, and mutated via DDL/DML over the VGI protocol.
Storage is currently in-memory; use a fresh worker process for an empty starting state. Cross-process state sharing (analogous to the SQLite-backed aggregate storage) is a follow-up.
Methods
method AttachOpaqueData
Section titled âmethod AttachOpaqueDataâfunc (c *WritableCatalog) AttachOpaqueData() []byteAttachOpaqueData returns the attach_opaque_data assigned to this catalog after first attach.
function NewWritableCatalog
Section titled âfunction NewWritableCatalogâfunc NewWritableCatalog(name string) *WritableCatalogNewWritableCatalog builds an empty writable catalog with one default schema âmainâ. The catalog uses a SQLite-backed store so DuckDB-spawned worker subprocesses see the same state.
struct catalogSchemaInfo
Section titled âstruct catalogSchemaInfoâtype catalogSchemaInfo struct {info *SchemaInfofunctions []FunctionInfotables []CatalogTableviews []CatalogViewmacros []CatalogMacro}type onConflictAction
Section titled âtype onConflictActionâtype onConflictAction stringDescription
onConflictAction encodes the SQL ON-CONFLICT semantics carried as a dictionary-encoded string by the C++ extension.
Methods
function parseOnConflict
Section titled âfunction parseOnConflictâfunc parseOnConflict(s string) onConflictActionstruct writableDeleteFn
Section titled âstruct writableDeleteFnâtype writableDeleteFn struct{ w *Worker }Methods
method ArgumentSpecs
Section titled âmethod ArgumentSpecsâfunc (f *writableDeleteFn) ArgumentSpecs() []ArgSpecArgumentSpecs declares the constant schema_name and table_name arguments.
method Finalize
Section titled âmethod Finalizeâfunc (f *writableDeleteFn) Finalize(ctx context.Context, p *ProcessParams, state interface{}) ([]arrow.RecordBatch, error)Finalize emits no additional batches; per-batch counts are returned inline.
method Metadata
Section titled âmethod Metadataâfunc (f *writableDeleteFn) Metadata() FunctionMetadataMetadata reports the function as a volatile, internal writable table function.
method Name
Section titled âmethod Nameâfunc (f *writableDeleteFn) Name() stringName returns the registered function name for the writable delete function.
method NewState
Section titled âmethod NewStateâfunc (f *writableDeleteFn) NewState(p *ProcessParams) (interface{}, error)NewState creates the per-call state holding the target schema and table names.
method OnBind
Section titled âmethod OnBindâfunc (f *writableDeleteFn) OnBind(p *BindParams) (*BindResponse, error)OnBind binds the output to a single-column ârows_deletedâ count schema.
method OnInit
Section titled âmethod OnInitâfunc (f *writableDeleteFn) OnInit(p *InitParams) (*GlobalInitResponse, error)OnInit limits processing to a single worker to serialize mutations.
method Process
Section titled âmethod Processâfunc (f *writableDeleteFn) Process(ctx context.Context, p *ProcessParams, state interface{}, batch arrow.RecordBatch, out *vgirpc.OutputCollector) errorProcess deletes rows identified by their synthesized row IDs in the incoming batch and emits the deleted row count.
struct writableInsertFn
Section titled âstruct writableInsertFnâtype writableInsertFn struct{ w *Worker }Methods
method ArgumentSpecs
Section titled âmethod ArgumentSpecsâfunc (f *writableInsertFn) ArgumentSpecs() []ArgSpecArgumentSpecs declares the constant schema_name and table_name arguments.
method Finalize
Section titled âmethod Finalizeâfunc (f *writableInsertFn) Finalize(ctx context.Context, p *ProcessParams, state interface{}) ([]arrow.RecordBatch, error)Finalize emits no additional batches; per-batch counts are returned inline.
method Metadata
Section titled âmethod Metadataâfunc (f *writableInsertFn) Metadata() FunctionMetadataMetadata reports the function as a volatile, internal writable table function.
method Name
Section titled âmethod Nameâfunc (f *writableInsertFn) Name() stringName returns the registered function name for the writable insert function.
method NewState
Section titled âmethod NewStateâfunc (f *writableInsertFn) NewState(p *ProcessParams) (interface{}, error)NewState creates the per-call state holding the target schema and table names.
method OnBind
Section titled âmethod OnBindâfunc (f *writableInsertFn) OnBind(p *BindParams) (*BindResponse, error)OnBind binds the output to a single-column ârows_insertedâ count schema.
method OnInit
Section titled âmethod OnInitâfunc (f *writableInsertFn) OnInit(p *InitParams) (*GlobalInitResponse, error)OnInit limits processing to a single worker to serialize mutations.
method Process
Section titled âmethod Processâfunc (f *writableInsertFn) Process(ctx context.Context, p *ProcessParams, state interface{}, batch arrow.RecordBatch, out *vgirpc.OutputCollector) errorProcess appends the incoming batch rows to the table and emits the inserted row count.
struct writableMutateState
Section titled âstruct writableMutateStateâtype writableMutateState struct {SchemaName stringTableName stringCount int64
// catalog memoizes the resolved writable catalog for the life of the// mutation (one DML statement). findWritableTable does a locked SQLite// QueryRow + schema-IPC deserialize + gob decode; without this cache every// input batch would repeat it. Unexported so gob ignores it on the HTTP// continuation round-trip (it re-resolves after rehydration).catalog *WritableCatalog}Methods
method resolveCatalog
Section titled âmethod resolveCatalogâfunc (st *writableMutateState) resolveCatalog(w *Worker) (*WritableCatalog, error)resolveCatalog returns the writable catalog owning this mutationâs table, resolving it once and caching it on the state.
struct writableScanFn
Section titled âstruct writableScanFnâtype writableScanFn struct{ w *Worker }Methods
method ArgumentSpecs
Section titled âmethod ArgumentSpecsâfunc (f *writableScanFn) ArgumentSpecs() []ArgSpecArgumentSpecs declares the constant schema_name and table_name arguments identifying the writable table to scan.
method Cardinality
Section titled âmethod Cardinalityâfunc (f *writableScanFn) Cardinality(params *BindParams) (*TableCardinality, error)Cardinality estimates the result size from the tableâs stored row count, returning zero if the table cannot be found.
method Metadata
Section titled âmethod Metadataâfunc (f *writableScanFn) Metadata() FunctionMetadataMetadata reports the function as a volatile, internal writable table function with projection pushdown enabled.
method Name
Section titled âmethod Nameâfunc (f *writableScanFn) Name() stringName returns the registered function name for the writable scan function.
method NewState
Section titled âmethod NewStateâfunc (f *writableScanFn) NewState(params *ProcessParams) (*writableScanState, error)NewState creates the per-scan state tracking whether rows have been emitted.
method OnBind
Section titled âmethod OnBindâfunc (f *writableScanFn) OnBind(params *BindParams) (*BindResponse, error)OnBind looks up the target table and binds the output to its schema plus a synthesized row-ID column.
method Process
Section titled âmethod Processâfunc (f *writableScanFn) Process(ctx context.Context, params *ProcessParams, state *writableScanState, out *vgirpc.OutputCollector) errorProcess emits all stored rows once as a single batch, honoring projection pushdown, then finishes the stream.
struct writableScanState
Section titled âstruct writableScanStateâtype writableScanState struct {Emitted bool // exported for gob round-trip via the framework}struct writableSchema
Section titled âstruct writableSchemaâtype writableSchema struct {name stringcomment stringtables map[string]*writableTable}struct writableStore
Section titled âstruct writableStoreâtype writableStore struct {mu sync.Mutexdb *sql.DBonce sync.OnceopenErr error}Description
writableStore is a SQLite-backed persistence layer that mirrors the in-memory writableSchema/writableTable/row data so DuckDB-spawned worker subprocesses see the same writable catalog state. Same rationale and same SQLite file as the aggregate state store.
Schema:
wc_schema(catalog, name PK, comment, created_version)wc_table(catalog, schema_name, name PK, schema_ipc, meta_blob, comment)wc_row(catalog, schema_name, table_name, row_id INTEGER PK auto, data_blob)meta_blob is a gob-encoded writableTableMeta capturing not-null /
PK / unique / check / FK / defaults / column comments â keeps the
table row narrow.
Methods
method ensureOpen
Section titled âmethod ensureOpenâfunc (s *writableStore) ensureOpen() errorfunction newWritableStore
Section titled âfunction newWritableStoreâfunc newWritableStore() *writableStoremethod rowsAppend
Section titled âmethod rowsAppendâfunc (s *writableStore) rowsAppend(catalog, schemaName, tableName string, rows []map[string]interface{}) (int64, error)rowsAppend writes new rows, returning the next row_id base.
method rowsCount
Section titled âmethod rowsCountâfunc (s *writableStore) rowsCount(catalog, schemaName, tableName string) (int64, error)rowsCount returns the number of rows for cardinality estimates.
method rowsDelete
Section titled âmethod rowsDeleteâfunc (s *writableStore) rowsDelete(catalog, schemaName, tableName string, rowIDs []int64) (int64, error)rowsDelete removes rows by row_id.
method rowsScan
Section titled âmethod rowsScanâfunc (s *writableStore) rowsScan(catalog, schemaName, tableName string) ([]map[string]interface{}, error)rowsScan returns all rows ordered by row_id, attaching the row_id under rowIDFieldName.
method rowsUpdate
Section titled âmethod rowsUpdateâfunc (s *writableStore) rowsUpdate(catalog, schemaName, tableName string, updates []map[string]interface{}) (int64, error)rowsUpdate replaces specified columns in rows identified by row_id.
method schemaDrop
Section titled âmethod schemaDropâfunc (s *writableStore) schemaDrop(catalog, name string, cascade bool) errormethod schemaExists
Section titled âmethod schemaExistsâfunc (s *writableStore) schemaExists(catalog, name string) (bool, error)method schemaList
Section titled âmethod schemaListâfunc (s *writableStore) schemaList(catalog string) ([]struct{ Name, Comment string }, error)method schemaUpsert
Section titled âmethod schemaUpsertâfunc (s *writableStore) schemaUpsert(catalog, name, comment string) errorschemaUpsert writes a schema record. Returns existing comment if found.
method tableDrop
Section titled âmethod tableDropâfunc (s *writableStore) tableDrop(catalog, schemaName, tableName string) errormethod tableList
Section titled âmethod tableListâfunc (s *writableStore) tableList(catalog, schemaName string) ([]string, error)method tableLoad
Section titled âmethod tableLoadâfunc (s *writableStore) tableLoad(catalog, schemaName, tableName string) (*writableTable, error)tableLoad fetches a table definition and rehydrates it (without rows).
method tableUpsert
Section titled âmethod tableUpsertâfunc (s *writableStore) tableUpsert(catalog, schemaName string, t *writableTable) errortableUpsert writes a table definition record.
struct writableTable
Section titled âstruct writableTableâtype writableTable struct {name stringschema *arrow.Schemacomment string// rows is the in-memory row store; each row is a map of column name// to Go value (nil for NULL).rows []map[string]interface{}// constraints captured at CREATE TABLE time.notNull []stringprimaryKey [][]stringunique [][]stringcheck []stringforeignKey []ForeignKeyConstraintdefaults map[string]anycolumnComment map[string]string}struct writableTableMeta
Section titled âstruct writableTableMetaâtype writableTableMeta struct {NotNull []stringPrimaryKey [][]stringUnique [][]stringCheck []stringForeignKey []ForeignKeyConstraintDefaults map[string][]byte // gob-encoded defaultValue per columnColumnComment map[string]string}Description
writableTableMeta is the gob-serializable per-table metadata.
Methods
function decodeTableMeta
Section titled âfunction decodeTableMetaâfunc decodeTableMeta(data []byte) (*writableTableMeta, error)method toDefaults
Section titled âmethod toDefaultsâfunc (m *writableTableMeta) toDefaults() map[string]anystruct writableUpdateFn
Section titled âstruct writableUpdateFnâtype writableUpdateFn struct{ w *Worker }Methods
method ArgumentSpecs
Section titled âmethod ArgumentSpecsâfunc (f *writableUpdateFn) ArgumentSpecs() []ArgSpecArgumentSpecs declares the constant schema_name and table_name arguments.
method Finalize
Section titled âmethod Finalizeâfunc (f *writableUpdateFn) Finalize(ctx context.Context, p *ProcessParams, state interface{}) ([]arrow.RecordBatch, error)Finalize emits no additional batches; per-batch counts are returned inline.
method Metadata
Section titled âmethod Metadataâfunc (f *writableUpdateFn) Metadata() FunctionMetadataMetadata reports the function as a volatile, internal writable table function.
method Name
Section titled âmethod Nameâfunc (f *writableUpdateFn) Name() stringName returns the registered function name for the writable update function.
method NewState
Section titled âmethod NewStateâfunc (f *writableUpdateFn) NewState(p *ProcessParams) (interface{}, error)NewState creates the per-call state holding the target schema and table names.
method OnBind
Section titled âmethod OnBindâfunc (f *writableUpdateFn) OnBind(p *BindParams) (*BindResponse, error)OnBind binds the output to a single-column ârows_updatedâ count schema.
method OnInit
Section titled âmethod OnInitâfunc (f *writableUpdateFn) OnInit(p *InitParams) (*GlobalInitResponse, error)OnInit limits processing to a single worker to serialize mutations.
method Process
Section titled âmethod Processâfunc (f *writableUpdateFn) Process(ctx context.Context, p *ProcessParams, state interface{}, batch arrow.RecordBatch, out *vgirpc.OutputCollector) errorProcess applies the incoming batch rows as updates to the table and emits the updated row count.
function BuildMacroArgumentsSchema
Section titled âfunction BuildMacroArgumentsSchemaâfunc BuildMacroArgumentsSchema(parameters []string, parameterDefaultValues []byte, parameterDocs map[string]string) ([]byte, error)BuildMacroArgumentsSchema builds the macro arguments_schema describing macro parameters, mirroring the function arguments_schema mechanism: one nullable Arrow field per parameter, in parameters order. Each parameterâs field type is the type of its default value when known (derived from parameterDefaultValues, the serialized 1-row RecordBatch of typed defaults) else arrow.Null. The per-parameter description rides as field metadata under the same vgi_doc key functions use (UTF-8, presence-only â the key is omitted entirely when there is no doc).
Returns nil when there are no parameters (nothing to describe). The returned bytes are Arrow IPC schema bytes suitable for MacroInfo.ArgumentsSchema and the macro create-request arguments_schema slot.
function BuildMacroDefaultValues
Section titled âfunction BuildMacroDefaultValuesâfunc BuildMacroDefaultValues(defaults []MacroDefault) ([]byte, error)BuildMacroDefaultValues builds the serialized Arrow IPC bytes for macro parameter defaults. Returns a 1-row RecordBatch where column names are parameter names and values are typed defaults.
function MacroParameterDocsFromSchema
Section titled âfunction MacroParameterDocsFromSchemaâfunc MacroParameterDocsFromSchema(argumentsSchema []byte) (map[string]string, error)MacroParameterDocsFromSchema extracts per-parameter descriptions from a macro arguments_schema (Arrow IPC schema bytes). Inverse of BuildMacroArgumentsSchemaâs vgi_doc handling: reads the vgi_doc field metadata (UTF-8) for each field. Fields without the key (undocumented) are omitted from the result. Returns an empty map when the input is empty or carries no docs.
function SerializeAttachCatalogInfo
Section titled âfunction SerializeAttachCatalogInfoâfunc SerializeAttachCatalogInfo(info AttachCatalogInfo) ([]byte, error)SerializeAttachCatalogInfo serializes one AttachCatalogInfo to IPC bytes matching AttachCatalogInfoSchema (alias, target, db_type, options, hidden, required, secret_ref).
function SerializeCatalogInfo
Section titled âfunction SerializeCatalogInfoâfunc SerializeCatalogInfo(info *CatalogInfo) ([]byte, error)SerializeCatalogInfo serializes a CatalogInfo to IPC bytes.
function SerializeColumnStatistics
Section titled âfunction SerializeColumnStatisticsâfunc SerializeColumnStatistics(stats []ColumnStatistics, cacheMaxAgeSeconds *int64) ([]byte, error)SerializeColumnStatistics encodes per-column stats as the sparse-union IPC batch DuckDBâs VGI extension expects. See vgi-pythonâs catalog_interface.serialize_column_statistics for the reference layout.
function SerializeFunctionInfo
Section titled âfunction SerializeFunctionInfoâfunc SerializeFunctionInfo(info *FunctionInfo) ([]byte, error)SerializeFunctionInfo serializes a FunctionInfo to IPC bytes.
function SerializeMacroInfo
Section titled âfunction SerializeMacroInfoâfunc SerializeMacroInfo(info *MacroInfo) ([]byte, error)SerializeMacroInfo serializes a MacroInfo to IPC bytes.
function SerializeScanBranch
Section titled âfunction SerializeScanBranchâfunc SerializeScanBranch(branch *ScanBranch) ([]byte, error)SerializeScanBranch serializes one ScanBranch to IPC bytes (the per-branch blob carried in ScanBranchesResult.branches).
function SerializeScanFunctionResult
Section titled âfunction SerializeScanFunctionResultâfunc SerializeScanFunctionResult(result *ScanFunctionResult) ([]byte, error)SerializeScanFunctionResult serializes a ScanFunctionResult to IPC bytes.
function SerializeSchemaInfo
Section titled âfunction SerializeSchemaInfoâfunc SerializeSchemaInfo(info *SchemaInfo) ([]byte, error)SerializeSchemaInfo serializes a SchemaInfo to IPC bytes.
function SerializeTableInfo
Section titled âfunction SerializeTableInfoâfunc SerializeTableInfo(info *TableInfo) ([]byte, error)SerializeTableInfo serializes a TableInfo to IPC bytes.
function SerializeViewInfo
Section titled âfunction SerializeViewInfoâfunc SerializeViewInfo(info *ViewInfo) ([]byte, error)SerializeViewInfo serializes a ViewInfo to IPC bytes.
function appendValue
Section titled âfunction appendValueâfunc appendValue(b array.Builder, val interface{})appendValue appends a Go value to the appropriate Arrow builder.
function applyColumnComments
Section titled âfunction applyColumnCommentsâfunc applyColumnComments(schema *arrow.Schema, comments map[string]string) (*arrow.Schema, error)applyColumnComments adds âcommentâ metadata to Arrow schema fields for columns with per-column descriptions. Existing metadata is preserved.
function applyDefaults
Section titled âfunction applyDefaultsâfunc applyDefaults(schema *arrow.Schema, defaults map[string]any) (*arrow.Schema, error)applyDefaults adds âdefaultâ metadata to Arrow schema fields for columns that have default values defined. Existing field metadata is preserved.
function applyGenerated
Section titled âfunction applyGeneratedâfunc applyGenerated(schema *arrow.Schema, generated map[string]string) (*arrow.Schema, error)applyGenerated adds âgenerated_expressionâ metadata to Arrow schema fields for generated/virtual columns. Existing field metadata is preserved.
function arrowValueAccessor
Section titled âfunction arrowValueAccessorâfunc arrowValueAccessor(col arrow.Array) func(i int) interface{}arrowValueAccessor resolves the concrete column type once and returns a per-row extractor, hoisting the type switch out of per-row loops. Unsupported types yield an accessor that returns nil (mirrors arrowValueAtâs default).
function arrowValueAt
Section titled âfunction arrowValueAtâfunc arrowValueAt(col arrow.Array, i int) interface{}arrowValueAt extracts one cell as a Go scalar. For per-cell loops over a whole column, resolve arrowValueAccessor once instead (this convenience form re-runs the type switch on every call).
function batchToRows
Section titled âfunction batchToRowsâfunc batchToRows(batch arrow.RecordBatch) ([]map[string]interface{}, error)batchToRows converts a RecordBatch into a slice of column-name â Go-value maps.
function buildColumnFromValues
Section titled âfunction buildColumnFromValuesâfunc buildColumnFromValues(mem memory.Allocator, f arrow.Field, rows []map[string]interface{}) (arrow.Array, error)function buildInt8Array
Section titled âfunction buildInt8Arrayâfunc buildInt8Array(mem memory.Allocator, data []int8) arrow.Arrayfunction buildStatChildArray
Section titled âfunction buildStatChildArrayâfunc buildStatChildArray(mem memory.Allocator, t arrow.DataType, target int8, codes []int8, stats []ColumnStatistics, wantMin bool) (arrow.Array, error)buildStatChildArray builds the per-type child array of a sparse union. Only rows whose typeCode matches the target are populated with the real value; others get null.
function catalogNameOf
Section titled âfunction catalogNameOfâfunc catalogNameOf(attachOpaqueData []byte) stringcatalogNameOf returns the catalog name carried in an unwrapped attach plaintext: the bytes before the first NUL separator, or the whole value when there is none. Alias-info catalogs (WithCatalogAliasInfo) mint â<name>\x00<random>â so each ATTACH is unique; plain catalogs/aliases use the bare name. Catalog-scoped function visibility compares against this name.
function columnGroupsByIndex
Section titled âfunction columnGroupsByIndexâfunc columnGroupsByIndex(schema *arrow.Schema, groups [][]int32) [][]stringfunction columnsByIndex
Section titled âfunction columnsByIndexâfunc columnsByIndex(schema *arrow.Schema, idx []int32) []stringfunction defaultToSQL
Section titled âfunction defaultToSQLâfunc defaultToSQL(value any) stringdefaultToSQL converts a Go default value to a SQL expression string.
function defaultsFromSchemaMetadata
Section titled âfunction defaultsFromSchemaMetadataâfunc defaultsFromSchemaMetadata(schema *arrow.Schema) map[string]anydefaultsFromSchemaMetadata extracts the default-value SQL expression stored as Arrow field metadata (key âdefaultâ) set by DuckDBâs column definition serializer.
function encodeTableMeta
Section titled âfunction encodeTableMetaâfunc encodeTableMeta(t *writableTable) []bytefunction makeUnionFields
Section titled âfunction makeUnionFieldsâfunc makeUnionFields(types []arrow.DataType, names []string) []arrow.Fieldfunction pickScalar
Section titled âfunction pickScalarâfunc pickScalar(s ColumnStatistics, wantMin bool) interface{}function resolveColumnGroupIndices
Section titled âfunction resolveColumnGroupIndicesâfunc resolveColumnGroupIndices(columns *arrow.Schema, groups [][]string) [][]int32resolveColumnGroupIndices maps groups of column names to groups of indices.
function resolveColumnIndices
Section titled âfunction resolveColumnIndicesâfunc resolveColumnIndices(columns *arrow.Schema, names []string) []int32resolveColumnIndices maps column names to their indices in the schema.
function rowsToBatch
Section titled âfunction rowsToBatchâfunc rowsToBatch(schema *arrow.Schema, rows []map[string]interface{}) (arrow.RecordBatch, error)rowsToBatch builds a RecordBatch from a slice of column-name â value maps.
function serializeAttachOptionSpec
Section titled âfunction serializeAttachOptionSpecâfunc serializeAttachOptionSpec(spec AttachOptionSpec) ([]byte, error)serializeAttachOptionSpec serializes an AttachOptionSpec to Arrow IPC bytes.
function serializeForeignKey
Section titled âfunction serializeForeignKeyâfunc serializeForeignKey(schemaName string, fk *ForeignKeyConstraint) ([]byte, error)serializeForeignKey serializes a ForeignKeyConstraint to IPC bytes.
function serializeInlineBindResult
Section titled âfunction serializeInlineBindResultâfunc serializeInlineBindResult(schema *arrow.Schema) ([]byte, error)serializeInlineBindResult produces the IPC bytes for an inlined bind result carrying a static output schema. It mirrors the payload a regular bind RPC would return (vgi-pythonâs BindResponse(output_schema=âŚ).serialize_to_bytes()): the given schema in output_schema, null opaque_data, and empty secret-lookup lists. Set on TableInfo.BindResult so the C++ extension threads it straight into bind_data and skips the per-scan bind RPC.
function serializeScanArgs
Section titled âfunction serializeScanArgsâfunc serializeScanArgs(mem memory.Allocator, positional []ScanArg, named map[string]ScanArg) ([]byte, error)serializeScanArgs builds and serializes the nested arguments batch. Positional args are named arg_0, arg_1, âŚ; named args use their name.
function suppliedAttachOptionNames
Section titled âfunction suppliedAttachOptionNamesâfunc suppliedAttachOptionNames(optionsIPC []byte) (map[string]struct{}, error)suppliedAttachOptionNames reads the option keys out of the serialized options batch. Each supplied option is a column of a single-row batch, so the column names are the keys; nil or empty bytes mean none were supplied.
function toFloat64
Section titled âfunction toFloat64âfunc toFloat64(v interface{}) float64function validateRequiredAttachOptions
Section titled âfunction validateRequiredAttachOptionsâfunc validateRequiredAttachOptions(catalogName string, specs []AttachOptionSpec, optionsIPC []byte) errorvalidateRequiredAttachOptions returns a *MissingAttachOptionsError when a spec marked Required has no corresponding entry in the supplied options. Names are matched case-insensitively, mirroring DuckDBâs handling of ATTACH option keys.
function validateRequiredFilters
Section titled âfunction validateRequiredFiltersâfunc validateRequiredFilters(tableName string, columns *arrow.Schema, groups [][]string) errorvalidateRequiredFilters checks a tableâs CNF required-filter groups. Each OR-group must be non-empty and contain no empty strings, and the leading dotted segment of every path must name a real column on the table. Returns nil when groups is empty (the no-enforcement fast path) or columns is nil.
function withSynthesizedRowID
Section titled âfunction withSynthesizedRowIDâfunc withSynthesizedRowID(s *arrow.Schema) *arrow.SchemawithSynthesizedRowID returns a new schema with __row_id (int64) appended if not already present.
function writableArgs
Section titled âfunction writableArgsâfunc writableArgs(args *Arguments) (string, string)function writableCountBatch
Section titled âfunction writableCountBatchâfunc writableCountBatch(name string, n int64) arrow.RecordBatchfunction writableCountSchema
Section titled âfunction writableCountSchemaâfunc writableCountSchema(name string) *arrow.Schema