vgi.catalog
Module overview
VGI Catalog Interface for exposing catalogs, schemas, tables, and views.
This module provides the abstract base class and data types for implementing catalog interfaces in VGI workers, enabling DuckDB ATTACH support.
class AttachCatalogInfo
Section titled âclass AttachCatalogInfoâBases: ArrowSerializableDataclass
Description
A companion catalog the client should ATTACH when this VGI catalog attaches.
Advertised via :attr:CatalogAttachResult.attach_catalogs. The VGI DuckDB
extension attaches each entry at VGI-attach time (into the clientâs
DatabaseManager) so that multi-branch catalog-table branches â and direct
user queries â can resolve tables in a companion lakehouse (DuckLake /
iceberg / postgres / âŚ) without the client hand-attaching anything.
Trust: companion attach is remote-influenced, so the extension applies a
scheme allowlist and a never-clobber conflict policy (it will never replace
a catalog it did not itself create). See docs/companion_catalogs.md.
Attributes
attribute alias
Section titled âattribute aliasâstr
Catalog name to attach as. Also the source_catalog a
catalog-table :class:ScanBranch references. Namespace this by
your catalog identity (e.g. "acme_lake") so two workers donât
both claim "lake" on the same client â collisions are rejected,
never silently merged.
attribute target
Section titled âattribute targetâstr
The ATTACH target â a path or DSN, e.g.
"ducklake:sqlite:/data/meta.sqlite" or
"postgres:dbname=⌠host=âŚ".
attribute db_type
Section titled âattribute db_typeâstr
DuckDB storage/db type (e.g. "ducklake", "postgres").
Empty â the extension infers it from the target scheme prefix.
attribute options
Section titled âattribute optionsâdict[str, str]
Extra ATTACH options forwarded verbatim (e.g. DuckLake
DATA_PATH). Keys are matched case-insensitively by DuckDB.
attribute hidden
Section titled âattribute hiddenâbool
When true, attach hidden (excluded from duckdb_databases());
still resolvable by qualified name and by branches. Use for
branch-only companions the user shouldnât see.
attribute required
Section titled âattribute requiredâbool
When true, a failure to attach (unreachable / conflict) fails the whole VGI ATTACH loudly. When false, the failure is logged and skipped; branches referencing it then error at bind.
attribute secret_ref
Section titled âattribute secret_refâstr
Optional name of a credential to pre-resolve (via the catalogâs Orchard secret provider) and inject into the companionâs ATTACH options â for metadata connections (e.g. a postgres DSN) where the catch-all path-keyed secret lookup isnât enough. Empty â rely on the automatic catch-all provider for data-file creds.
class Catalog
Section titled âclass CatalogâDescription
Declarative catalog definition containing schemas.
The single entry point for defining all catalog metadata on a Worker.
Attributes
attribute name
Section titled âattribute nameâstr
The catalog name (used in SQL as the database name).
attribute default_schema
Section titled âattribute default_schemaâstr
Schema to use for unqualified table/view/function names.
attribute schemas
Section titled âattribute schemasâSequence[Schema]
Sequence of Schema objects defining the catalog contents.
attribute comment
Section titled âattribute commentâstr | None
Optional comment describing the catalog.
attribute tags
Section titled âattribute tagsâdict[str, str]
Optional key-value tags associated with the catalog.
attribute source_url
Section titled âattribute source_urlâstr | None
Where this workerâs code lives â repo, build, or docs
homepage. None (the default) when the worker doesnât advertise
a source location. Surfaced via the catalog_catalogs() discovery
record (CatalogInfo.source_url).
attribute global_functions
Section titled âattribute global_functionsâSequence[type[Function]]
Functions to additionally publish into the clientâs
global function namespace (DuckDBâs system.main), so they can be
called unqualified without naming this catalog â the way
ducklake_table_info is reachable after LOAD ducklake. Use
this for utility functions that arenât about a particular attached
catalog (diagnostics, converters, helpers).
Every entry must also appear in exactly one Schema.functions:
bind dispatch is keyed on (schema_name, name), so a function
that exists only here would be registered but never dispatchable.
The schema-qualified name keeps working and is the unambiguous
fallback when a global name is claimed by another worker.
Registration is first-attach-wins and best-effort â a name already owned by a different worker is skipped, and the client may disable the whole mechanism per-ATTACH. Never rely on a global name resolving; treat it as an ergonomic alias.
attribute global_function_prefix
Section titled âattribute global_function_prefixâstr | None
Prefix applied to each global_functions
entry to form its globally visible name (<prefix>_<name>).
None publishes bare names, which is more collision-prone â
prefer a prefix that identifies this worker.
class CatalogAttachResult
Section titled âclass CatalogAttachResultâBases: ArrowSerializableDataclass
Description
Result from attaching to a catalog.
Attributes
attribute attach_opaque_data
Section titled âattribute attach_opaque_dataâAttachOpaqueData
The unique id for the attached catalog.
attribute supports_transactions
Section titled âattribute supports_transactionsâbool
Indicate if the worker supports transactions or not. If false, all transaction related methods will not be called and all transaction_opaque_data parameters will be None.
attribute supports_time_travel
Section titled âattribute supports_time_travelâbool
Indicate if tables support time travel.
attribute catalog_version_frozen
Section titled âattribute catalog_version_frozenâbool
Indicate that the catalog version id is frozen and the schema and object information will not change.
attribute catalog_version
Section titled âattribute catalog_versionâint
The initial catalog version, it increments when schemas, tables or other objects change.
attribute attach_opaque_data_required
Section titled âattribute attach_opaque_data_requiredâbool
Indicate if the attach_opaque_data must be persisted across commands. True: Catalog is stateful; attach_opaque_data represents a session. False: Catalog is stateless; CLI can auto-attach on each command.
attribute default_schema
Section titled âattribute default_schemaâstr
The name of the default schema for this catalog.
attribute settings
Section titled âattribute settingsâlist[bytes]
Extension options (settings) exposed by this catalog/worker. Each ExtensionOption is serialized as bytes for Arrow compatibility.
attribute secret_types
Section titled âattribute secret_typesâlist[bytes]
Secret types registered with DuckDBâs SecretManager. Each SecretTypeSpec is serialized as bytes for Arrow compatibility.
attribute attach_catalogs
Section titled âattribute attach_catalogsâlist[bytes]
Companion catalogs the client should ATTACH alongside
this VGI catalog (lakehouse federation). Each :class:AttachCatalogInfo
is serialized as bytes for Arrow compatibility. Attached at
VGI-attach time; detached (refcounted) on DETACH. See
AttachCatalogInfo and docs/companion_catalogs.md.
attribute comment
Section titled âattribute commentâstr | None
Optional comment describing this catalog/database.
attribute tags
Section titled âattribute tagsâdict[str, str]
Optional key-value tags associated with this catalog/database.
attribute supports_column_statistics
Section titled âattribute supports_column_statisticsâbool
Whether any tables in this catalog can provide column statistics. Global gate â if False, GetStatistics() returns nullptr for all tables.
attribute global_functions
Section titled âattribute global_functionsâlist[bytes]
Functions this catalog asks the client to publish into
the global function namespace (DuckDBâs system.main), in
addition to their normal schema-qualified registration. Each
:class:FunctionInfo is serialized as bytes for Arrow
compatibility. name/schema_name stay the real dispatch
coordinates â the client derives the globally visible name by
applying global_function_prefix. Registration is
first-attach-wins: a name already owned by a different worker is
skipped (logged), and the ATTACH still succeeds. Empty list = this
catalog publishes nothing globally. See docs/global-functions.md.
attribute global_function_prefix
Section titled âattribute global_function_prefixâstr
Prefix applied to every global_functions
entry to form its globally visible name (<prefix>_<name>).
Empty string = publish bare names, which is more collision-prone;
prefer a prefix that identifies the worker.
attribute resolved_data_version
Section titled âattribute resolved_data_versionâstr | None
Concrete data version the worker resolved for
this attach. None = worker has no opinion or the request omitted
data_version_spec.
attribute resolved_implementation_version
Section titled âattribute resolved_implementation_versionâstr | None
Concrete implementation version the
worker resolved for this attach. None = worker has no opinion or
the request omitted implementation_version.
class CatalogDataVersionRelease
Section titled âclass CatalogDataVersionReleaseâBases: ArrowSerializableDataclass
Description
One published data version of a catalog.
data_version_spec advertises a compatibility range; this record
advertises whatâs actually been published. Together they let a
client (the describe page, Cupola, programmatic consumers) render a
discoverable release timeline without scraping the workerâs repo.
Contracts on the CatalogInfo.releases list this belongs to:
- Ordering â entries MUST appear newest-first. Unspecified order
would force consumers to sort by
versionstring, which requires a comparator the protocol does not define (semver vs. calver vs. date-stamped vs. RC tags are all valid). - Uniqueness â each
versionMUST appear at most once. Mirrors the same invariant onattach_option_specsâsname. Consumers defend against duplicates (log-and-skip later entries) since Arrow cannot enforce key uniqueness at the wire level.
Long-form release notes do not live here â link to a CHANGELOG anchor,
GitHub release page, PR, or migration guide via notes_url.
Attributes
attribute version
Section titled âattribute versionâstr
Concrete version, not a spec. e.g. â1.0.0â, â2.4.1â. Semver carries the breaking-change signal directly â major bumps are breaking, minor/patch are not.
attribute released_at
Section titled âattribute released_atâAnnotated[datetime | None, ArrowType(pa.timestamp(us, tz=UTC))]
Release date (UTC). None when the worker doesnât
track dates.
attribute summary
Section titled âattribute summaryâstr
One-line human summary. Empty string when unknown.
attribute notes_url
Section titled âattribute notes_urlâstr | None
Optional per-release link to detailed notes. Distinct from
CatalogInfo.source_url (which points at the repo as a whole):
this points at what changed in this release.
class CatalogExample
Section titled âclass CatalogExampleâBases: ArrowSerializableDataclass
Description
An example usage of a function for catalog serialization.
Attributes
attribute expected_output
Section titled âattribute expected_outputâstr | None
Optional expected result description.
class CatalogInfo
Section titled âclass CatalogInfoâBases: ArrowSerializableDataclass
Description
Discovery record for a catalog exposed by a worker.
Returned by catalog_catalogs() so clients can inspect per-catalog version
metadata before attaching.
Attributes
attribute name
Section titled âattribute nameâstr
Catalog name â pass to catalog_attach() to open it.
attribute implementation_version
Section titled âattribute implementation_versionâstr | None
Worker software version (singular per worker).
None = worker declares no implementation version.
attribute data_version_spec
Section titled âattribute data_version_specâstr | None
Semver range the catalog serves (e.g.
â>=1.0.0,<2.0.0â). None = worker declares no data-version
opinion.
attribute attach_option_specs
Section titled âattribute attach_option_specsâlist[bytes]
Attach-time options the catalog accepts (distinct from session settings). Each AttachOptionSpec is serialized as bytes for Arrow compatibility. Enables pre-attach discovery via the catalogs() RPC.
attribute releases
Section titled âattribute releasesâlist[CatalogDataVersionRelease]
Concrete published data versions, newest-first. Empty when the
worker doesnât track release history. See
CatalogDataVersionRelease for the per-entry ordering and
uniqueness contracts.
attribute source_url
Section titled âattribute source_urlâstr | None
Where this workerâs code lives â repo, build, docs. None
when the worker doesnât advertise a source location.
class CatalogInterface
Section titled âclass CatalogInterfaceâBases: ABC
Description
Provides an interface to manage catalogs, schemas, tables, and views for VGI.
This interface defines methods for creating, dropping, and managing catalogs, schemas, tables, and views. It also supports transactions and provides methods for discovering catalog contents.
Implementors of this interface should provide concrete implementations for all abstract methods and properties.
Api limitations
- Functions are not able to be created or dropped.
- Tags are not able to be updated on catalog objects.
- Comments and tags are not updatable on schemas (
SchemaInfo). - Constraints cannot be added/dropped (except NOT NULL).
A VGI worker will offer a single implementation of this interface to clients to manage their catalogs.
Attributes
attribute interface_feature_flags
Section titled âattribute interface_feature_flagsâset[str]
Get the feature flags supported by this CatalogInterface.
Feature flags indicate optional capabilities of the implementation. The default implementation returns an empty set.
Methods
method loggable_attach_options
Section titled âmethod loggable_attach_optionsâloggable_attach_options(
options: Mapping[str, Any],
) -> Mapping[str, Any]Return a redacted view of attach/create options safe for logs and Sentry breadcrumbs.
Called by the worker when emitting catalog lifecycle events
(catalog.attach, catalog.create). Override to opt in to
logging the option fields you know are safe â host names, regions,
bucket names, etc. Never return credentials such as passwords,
tokens, or connection strings containing secrets.
Default returns an empty mapping, so by default nothing from the
options dict is logged. This fail-closed behaviour avoids
leaking credentials when an implementer has not explicitly chosen
which fields are safe to emit.
method catalogs
Section titled âmethod catalogsâcatalogs() -> list[CatalogInfo]Get a list of catalog discovery records provided by the VGI worker.
Each record carries the catalog name and â if the worker has opinions â its implementation_version and data_version_spec, so clients can prevalidate ATTACH requests.
This is a discovery only method.
method catalog_create
Section titled âmethod catalog_createâcatalog_create(
*,
name: str,
on_conflict: OnConflict,
options: dict[str, Any],
) -> NoneCreate a new catalog with the given name.
If on_conflict is IGNORE and the catalog already exists, do nothing. If on_conflict is REPLACE and the catalog already exists, replace it. If on_conflict is ERROR and the catalog already exists, raise an error.
method catalog_drop
Section titled âmethod catalog_dropâcatalog_drop(*, name: str) -> NoneDrop the catalog with the given name.
method catalog_transaction_begin
Section titled âmethod catalog_transaction_beginâcatalog_transaction_begin(
*,
attach_opaque_data: AttachOpaqueData,
) -> TransactionOpaqueData | NoneBegin a new transaction for the given attach_opaque_data.
If the implementation does not support transactions, it can return None.
method catalog_transaction_commit
Section titled âmethod catalog_transaction_commitâcatalog_transaction_commit(
*,
attach_opaque_data: AttachOpaqueData,
transaction_opaque_data: TransactionOpaqueData,
) -> NoneCommit the transaction for the given attachment.
If the transaction cannot be committed, an exception should be raised.
method catalog_transaction_rollback
Section titled âmethod catalog_transaction_rollbackâcatalog_transaction_rollback(
*,
attach_opaque_data: AttachOpaqueData,
transaction_opaque_data: TransactionOpaqueData,
) -> NoneRollback the transaction for the given attachment.
If the transaction cannot be rolled back, an exception should be raised.
method catalog_attach
Section titled âmethod catalog_attachâcatalog_attach(
*,
name: str,
options: dict[str, Any],
data_version_spec: str | None,
implementation_version: str | None,
ctx: CallContext | None = None,
) -> CatalogAttachResultAttach to a catalog with the given name and options.
data_version_spec and implementation_version carry the
semver constraints the client requested at ATTACH time. Pass-through
strings â subclasses interpret and validate them. None means
the client did not constrain that dimension. Implementations that
cannot satisfy a requested version MUST raise an exception with a
human-readable message; the error surfaces on the client as the
ATTACH failure.
ctx is injected by the RPC dispatcher when available. Over HTTP it
enables setting a per-session routing cookie via ctx.set_cookie();
over subprocess it may be None or have empty cookie support.
Returns a CatalogAttachResult containing the attach ID, other catalog
metadata, and the resolved concrete versions chosen by the worker.
method catalog_detach
Section titled âmethod catalog_detachâcatalog_detach(*, attach_opaque_data: AttachOpaqueData) -> NoneDetach from the catalog with the given attach_opaque_data.
Any open transactions should be rolled back. The default implementation does nothing.
method catalog_version
Section titled âmethod catalog_versionâcatalog_version(
*,
attach_opaque_data: AttachOpaqueData,
transaction_opaque_data: TransactionOpaqueData | None,
ctx: CallContext | None = None,
) -> intGet the current catalog version for the given attach_opaque_data and transaction_opaque_data.
Returns an integer representing the current catalog version.
Changes to schemas, tables, and objects increment this version. It is used to expire cached catalog/schema/object information inside a VGI client or process.
ctx is injected by the RPC dispatcher when available. Subclasses that use
HTTP-session cookies can consult ctx.cookies to verify routing
stickiness.
The default implementation returns 0.
method schemas
Section titled âmethod schemasâschemas(
*,
attach_opaque_data: AttachOpaqueData,
transaction_opaque_data: TransactionOpaqueData | None,
) -> list[SchemaInfo]Get a list of schemas for the given attach_opaque_data and transaction_opaque_data.
The default returns a schema called âmainâ with no comment or tags.
method schema_create
Section titled âmethod schema_createâschema_create(
*,
attach_opaque_data: AttachOpaqueData,
transaction_opaque_data: TransactionOpaqueData | None,
name: str,
on_conflict: OnConflict = OnConflict.ERROR,
comment: str | None,
tags: dict[str, str],
) -> NoneCreate a new schema with the given name, comment, and tags.
method schema_drop
Section titled âmethod schema_dropâschema_drop(
*,
attach_opaque_data: AttachOpaqueData,
transaction_opaque_data: TransactionOpaqueData | None,
name: str,
ignore_not_found: bool,
cascade: bool,
) -> NoneDrop the schema with the given name.
method schema_contents
Section titled âmethod schema_contentsâschema_contents(
*,
attach_opaque_data: AttachOpaqueData,
transaction_opaque_data: TransactionOpaqueData | None,
name: str,
type: SchemaObjectType,
) -> Sequence[TableInfo | ViewInfo | FunctionInfo | MacroInfo | IndexInfo]Get the contents of the schema with the given name.
Schemas can contain tables, views, functions, macros, and indexes.
method schema_get
Section titled âmethod schema_getâschema_get(
*,
attach_opaque_data: AttachOpaqueData,
transaction_opaque_data: TransactionOpaqueData | None,
name: str,
) -> SchemaInfo | NoneGet information about the schema with the given name.
Returns a SchemaInfo object if the schema exists, or None if it does not.
method table_get
Section titled âmethod table_getâtable_get(
*,
attach_opaque_data: AttachOpaqueData,
transaction_opaque_data: TransactionOpaqueData | None,
schema_name: str,
name: str,
at_unit: str | None = None,
at_value: str | None = None,
) -> TableInfo | NoneGet information about the table with the given name in the specified schema.
When at_unit / at_value are provided the implementation should
return the table schema for the requested point in time (time travel).
Returns a TableInfo object if the table exists, or None if it does not.
method table_create
Section titled âmethod table_createâtable_create(
*,
attach_opaque_data: AttachOpaqueData,
transaction_opaque_data: TransactionOpaqueData | None,
schema_name: str,
name: str,
columns: SerializedSchema,
on_conflict: OnConflict,
not_null_constraints: list[int],
unique_constraints: list[list[int]],
check_constraints: list[str],
primary_key_constraints: list[list[int]] | None = None,
foreign_key_constraints: list[bytes] | None = None,
) -> NoneCreate a new table with the given name and schema.
Comments and tags are not supported on table creation.
method table_drop
Section titled âmethod table_dropâtable_drop(
*,
attach_opaque_data: AttachOpaqueData,
transaction_opaque_data: TransactionOpaqueData | None,
schema_name: str,
name: str,
ignore_not_found: bool,
cascade: bool = False,
) -> NoneDrop the table with the given name.
method table_comment_set
Section titled âmethod table_comment_setâtable_comment_set(
*,
attach_opaque_data: AttachOpaqueData,
transaction_opaque_data: TransactionOpaqueData | None,
schema_name: str,
name: str,
comment: str | None,
ignore_not_found: bool,
) -> NoneSet the comment for the table with the given name.
method table_column_comment_set
Section titled âmethod table_column_comment_setâtable_column_comment_set(
*,
attach_opaque_data: AttachOpaqueData,
transaction_opaque_data: TransactionOpaqueData | None,
schema_name: str,
name: str,
column_name: str,
comment: str | None,
ignore_not_found: bool,
) -> NoneSet the comment for a column in the table.
method table_rename
Section titled âmethod table_renameâtable_rename(
*,
attach_opaque_data: AttachOpaqueData,
transaction_opaque_data: TransactionOpaqueData | None,
schema_name: str,
name: str,
new_name: str,
ignore_not_found: bool,
) -> NoneRename the table with the given name to the new name.
method table_column_add
Section titled âmethod table_column_addâtable_column_add(
*,
attach_opaque_data: AttachOpaqueData,
transaction_opaque_data: TransactionOpaqueData | None,
schema_name: str,
name: str,
column_definition: SerializedSchema,
ignore_not_found: bool,
if_column_not_exists: bool,
) -> NoneAdd a column to the table with the given name.
method table_column_drop
Section titled âmethod table_column_dropâtable_column_drop(
*,
attach_opaque_data: AttachOpaqueData,
transaction_opaque_data: TransactionOpaqueData | None,
schema_name: str,
name: str,
column_name: str,
ignore_not_found: bool,
if_column_exists: bool,
cascade: bool,
) -> NoneDrop the column from the table with the given name.
method table_column_rename
Section titled âmethod table_column_renameâtable_column_rename(
*,
attach_opaque_data: AttachOpaqueData,
transaction_opaque_data: TransactionOpaqueData | None,
schema_name: str,
name: str,
column_name: str,
new_column_name: str,
ignore_not_found: bool,
) -> NoneRename the column in the table with the given name.
method table_column_default_set
Section titled âmethod table_column_default_setâtable_column_default_set(
*,
attach_opaque_data: AttachOpaqueData,
transaction_opaque_data: TransactionOpaqueData | None,
schema_name: str,
name: str,
column_name: str,
expression: SqlExpression,
ignore_not_found: bool,
) -> NoneSet the default expression for the column.
method table_column_default_drop
Section titled âmethod table_column_default_dropâtable_column_default_drop(
*,
attach_opaque_data: AttachOpaqueData,
transaction_opaque_data: TransactionOpaqueData | None,
schema_name: str,
name: str,
column_name: str,
ignore_not_found: bool,
) -> NoneDrop the default expression for the column.
method table_column_type_change
Section titled âmethod table_column_type_changeâtable_column_type_change(
*,
attach_opaque_data: AttachOpaqueData,
transaction_opaque_data: TransactionOpaqueData | None,
schema_name: str,
name: str,
column_definition: SerializedSchema,
expression: SqlExpression | None,
ignore_not_found: bool,
) -> NoneChange the type of the column in the table with the given name.
The name of the column to change is taken from the field in the provided schema.
method table_not_null_drop
Section titled âmethod table_not_null_dropâtable_not_null_drop(
*,
attach_opaque_data: AttachOpaqueData,
transaction_opaque_data: TransactionOpaqueData | None,
schema_name: str,
name: str,
column_name: str,
ignore_not_found: bool,
) -> NoneDrop the NOT NULL constraint from the column.
method table_not_null_set
Section titled âmethod table_not_null_setâtable_not_null_set(
*,
attach_opaque_data: AttachOpaqueData,
transaction_opaque_data: TransactionOpaqueData | None,
schema_name: str,
name: str,
column_name: str,
ignore_not_found: bool,
) -> NoneSet the NOT NULL constraint on the column.
method table_scan_function_get
Section titled âmethod table_scan_function_getâtable_scan_function_get(
*,
attach_opaque_data: AttachOpaqueData,
transaction_opaque_data: TransactionOpaqueData | None,
schema_name: str,
name: str,
at_unit: str | None,
at_value: str | None,
) -> ScanFunctionResultGet the ScanFunctionResult for scanning the table.
Returns information about the VGI table function to call when scanning this table. The at_unit and at_value support time travel queries.
method table_scan_branches_get
Section titled âmethod table_scan_branches_getâtable_scan_branches_get(
*,
attach_opaque_data: AttachOpaqueData,
transaction_opaque_data: TransactionOpaqueData | None,
schema_name: str,
name: str,
at_unit: str | None,
at_value: str | None,
) -> ScanBranchesResultGet the list of scan branches for a multi-source table.
Multi-branch tables compose a logical scan from N physical sources
(canonical case: Kafka hot tier + Iceberg cold tier). The VGI DuckDB
extensionâs optimizer-extension rewrites the placeholder LogicalGet
into LogicalSetOperation(UNION_ALL, ...), one arm per branch.
Default implementation: delegate to :meth:table_scan_function_get
and wrap the single ScanFunctionResult as a one-branch list.
This makes every existing single-source worker automatically
compatible with the new branches-aware C++ side, while letting
workers that genuinely need multi-source override this method.
Workers that override should NOT also raise from
:meth:table_scan_function_get â the legacy method must keep
working for old C++ extensions that donât yet probe for the new
branches RPC. Common pattern: a worker implements both, where
:meth:table_scan_function_get returns branches[0] (the
primary branch) and :meth:table_scan_branches_get returns the
full list.
method table_column_statistics_get
Section titled âmethod table_column_statistics_getâtable_column_statistics_get(
*,
attach_opaque_data: AttachOpaqueData,
transaction_opaque_data: TransactionOpaqueData | None,
schema_name: str,
name: str,
) -> TableColumnStatisticsResult | NoneGet column statistics for all columns in a table.
Returns a :class:TableColumnStatisticsResult containing per-column
statistics and an optional cache TTL, or None if statistics are not
available for this table.
The default implementation returns None (no statistics).
Workers that provide statistics should override this method.
method table_insert_function_get
Section titled âmethod table_insert_function_getâtable_insert_function_get(
*,
attach_opaque_data: AttachOpaqueData,
transaction_opaque_data: TransactionOpaqueData | None,
schema_name: str,
name: str,
writable_branch_function_name: str | None = None,
) -> ScanFunctionResultGet the write function for INSERT operations on the table.
Returns a ScanFunctionResult identifying the TableInOutGenerator function
to call for inserting rows into this table.
writable_branch_function_name is set by the C++ extension when the
table is multi-branch and a branch declared writable=True: the value
is the writable armâs ScanBranch.function_name. Workers serving
multi-branch tables can use this to dispatch the INSERT to the correct
underlying storage without re-resolving the writable arm internally.
For single-branch tables this is None (or unset for legacy
overrides).
method table_update_function_get
Section titled âmethod table_update_function_getâtable_update_function_get(
*,
attach_opaque_data: AttachOpaqueData,
transaction_opaque_data: TransactionOpaqueData | None,
schema_name: str,
name: str,
) -> ScanFunctionResultGet the write function for UPDATE operations on the table.
Returns a ScanFunctionResult identifying the TableInOutGenerator function
to call for updating rows in this table. Input batches will include a
rowid column plus the columns being updated.
method table_delete_function_get
Section titled âmethod table_delete_function_getâtable_delete_function_get(
*,
attach_opaque_data: AttachOpaqueData,
transaction_opaque_data: TransactionOpaqueData | None,
schema_name: str,
name: str,
) -> ScanFunctionResultGet the write function for DELETE operations on the table.
Returns a ScanFunctionResult identifying the TableInOutGenerator function
to call for deleting rows from this table. Input batches will contain
a rowid column identifying the rows to delete.
method view_create
Section titled âmethod view_createâview_create(
*,
attach_opaque_data: AttachOpaqueData,
transaction_opaque_data: TransactionOpaqueData | None,
schema_name: str,
name: str,
definition: str,
on_conflict: OnConflict,
) -> NoneCreate a new view with the given definition.
method view_drop
Section titled âmethod view_dropâview_drop(
*,
attach_opaque_data: AttachOpaqueData,
transaction_opaque_data: TransactionOpaqueData | None,
schema_name: str,
name: str,
ignore_not_found: bool,
cascade: bool = False,
) -> NoneDrop the view with the given name.
method view_rename
Section titled âmethod view_renameâview_rename(
*,
attach_opaque_data: AttachOpaqueData,
transaction_opaque_data: TransactionOpaqueData | None,
schema_name: str,
name: str,
new_name: str,
ignore_not_found: bool,
) -> NoneRename the view to the new name.
method view_get
Section titled âmethod view_getâview_get(
*,
attach_opaque_data: AttachOpaqueData,
transaction_opaque_data: TransactionOpaqueData | None,
schema_name: str,
name: str,
) -> ViewInfo | NoneGet information about the view with the given name.
Returns a ViewInfo object if the view exists, or None if it does not.
method view_comment_set
Section titled âmethod view_comment_setâview_comment_set(
*,
attach_opaque_data: AttachOpaqueData,
transaction_opaque_data: TransactionOpaqueData | None,
schema_name: str,
name: str,
comment: str | None,
ignore_not_found: bool,
) -> NoneSet the comment for the view with the given name.
method macro_get
Section titled âmethod macro_getâmacro_get(
*,
attach_opaque_data: AttachOpaqueData,
transaction_opaque_data: TransactionOpaqueData | None,
schema_name: str,
name: str,
) -> MacroInfo | NoneGet information about the macro with the given name.
Returns a MacroInfo object if the macro exists, or None if it does not.
method macro_create
Section titled âmethod macro_createâmacro_create(
*,
attach_opaque_data: AttachOpaqueData,
transaction_opaque_data: TransactionOpaqueData | None,
schema_name: str,
name: str,
macro_type: MacroType,
parameters: list[str],
definition: str,
on_conflict: OnConflict,
parameter_default_values: pa.RecordBatch | None = None,
arguments_schema: pa.Schema | None = None,
) -> NoneCreate a new macro with the given definition.
method macro_drop
Section titled âmethod macro_dropâmacro_drop(
*,
attach_opaque_data: AttachOpaqueData,
transaction_opaque_data: TransactionOpaqueData | None,
schema_name: str,
name: str,
ignore_not_found: bool,
) -> NoneDrop the macro with the given name.
method index_get
Section titled âmethod index_getâindex_get(
*,
attach_opaque_data: AttachOpaqueData,
transaction_opaque_data: TransactionOpaqueData | None,
schema_name: str,
name: str,
) -> IndexInfo | NoneGet information about the index with the given name.
Returns an IndexInfo object if the index exists, or None if it does not.
The default implementation returns None (no indexes).
method index_create
Section titled âmethod index_createâindex_create(
*,
attach_opaque_data: AttachOpaqueData,
transaction_opaque_data: TransactionOpaqueData | None,
schema_name: str,
name: str,
table_name: str,
index_type: str,
constraint_type: IndexConstraintType,
expressions: list[str],
on_conflict: OnConflict,
options: dict[str, str] | None = None,
) -> NoneCreate a new index on the specified table.
method index_drop
Section titled âmethod index_dropâindex_drop(
*,
attach_opaque_data: AttachOpaqueData,
transaction_opaque_data: TransactionOpaqueData | None,
schema_name: str,
name: str,
ignore_not_found: bool,
cascade: bool = False,
) -> NoneDrop the index with the given name.
method copy_from_formats
Section titled âmethod copy_from_formatsâcopy_from_formats(
*,
attach_opaque_data: AttachOpaqueData,
transaction_opaque_data: TransactionOpaqueData | None,
) -> list[CopyFromFormatInfo]List custom COPY ... FROM formats advertised by this catalog.
Catalog-level (not schema-scoped). The default returns an empty list, so
catalogs that donât define COPY formats are unaffected. The VGI extension
registers one DuckDB CopyFunction per returned entry at ATTACH time.
class CatalogObject
Section titled âclass CatalogObjectâDescription
All objects have the following common properties.
Attributes
attribute comment
Section titled âattribute commentâstr | None
This is a generic comment about the object.
attribute tags
Section titled âattribute tagsâdict[str, str]
These are key-value tags associated with the object.
class CatalogSchemaObject
Section titled âclass CatalogSchemaObjectâBases: CatalogObject
Description
Objects that exist within a schema have the following common properties.
Attributes
attribute schema_name
Section titled âattribute schema_nameâstr
The name of the schema containing the object.
Inherited members (2)
commentattribute ¡ from CatalogObjecttagsattribute ¡ from CatalogObject
class CatalogStorage
Section titled âclass CatalogStorageâBases: Protocol
Description
Storage protocol for VGI catalog state persistence.
Provides two access patterns for catalog state:
Attachments - Track catalog attachments with their options. Stores the mapping from attach_opaque_data to catalog name and options.
Transactions - Track active transactions. Stores transaction state for catalogs that support transactions.
Methods
method attach_put
Section titled âmethod attach_putâattach_put(
attach_opaque_data: AttachOpaqueData,
catalog_name: str,
options: dict[str, Any],
) -> NoneStore attachment state.
method attach_get
Section titled âmethod attach_getâattach_get(
attach_opaque_data: AttachOpaqueData,
) -> tuple[str, dict[str, Any]] | NoneRetrieve attachment state by attach_opaque_data.
method attach_delete
Section titled âmethod attach_deleteâattach_delete(attach_opaque_data: AttachOpaqueData) -> NoneDelete attachment state.
method attach_list
Section titled âmethod attach_listâattach_list() -> list[AttachOpaqueData]List all active attachments.
method transaction_put
Section titled âmethod transaction_putâtransaction_put(
transaction_opaque_data: TransactionOpaqueData,
attach_opaque_data: AttachOpaqueData,
state: bytes,
) -> NoneStore transaction state.
method transaction_get
Section titled âmethod transaction_getâtransaction_get(
transaction_opaque_data: TransactionOpaqueData,
) -> tuple[AttachOpaqueData, bytes] | NoneRetrieve transaction state.
method transaction_delete
Section titled âmethod transaction_deleteâtransaction_delete(
transaction_opaque_data: TransactionOpaqueData,
) -> NoneDelete transaction state.
class CatalogStorageSqlite
Section titled âclass CatalogStorageSqliteâDescription
SQLite-backed storage for VGI catalog state.
This implementation uses SQLite with WAL mode to allow multiple worker processes to share catalog state. It manages two tables:
- catalog_attachments: Maps attach_opaque_data to catalog name and options
- catalog_transactions: Tracks active transactions
Attributes
attribute db_path
Section titled âattribute db_pathâstr
Filesystem path to the backing SQLite database file.
Methods
method attach_put
Section titled âmethod attach_putâattach_put(
attach_opaque_data: AttachOpaqueData,
catalog_name: str,
options: dict[str, Any],
) -> NoneStore attachment state.
method attach_get
Section titled âmethod attach_getâattach_get(
attach_opaque_data: AttachOpaqueData,
) -> tuple[str, dict[str, Any]] | NoneRetrieve attachment state by attach_opaque_data.
method attach_delete
Section titled âmethod attach_deleteâattach_delete(attach_opaque_data: AttachOpaqueData) -> NoneDelete attachment state.
method attach_list
Section titled âmethod attach_listâattach_list() -> list[AttachOpaqueData]List all active attachment IDs.
method transaction_put
Section titled âmethod transaction_putâtransaction_put(
transaction_opaque_data: TransactionOpaqueData,
attach_opaque_data: AttachOpaqueData,
state: bytes,
) -> NoneStore transaction state.
method transaction_get
Section titled âmethod transaction_getâtransaction_get(
transaction_opaque_data: TransactionOpaqueData,
) -> tuple[AttachOpaqueData, bytes] | NoneRetrieve transaction state.
method transaction_delete
Section titled âmethod transaction_deleteâtransaction_delete(
transaction_opaque_data: TransactionOpaqueData,
) -> NoneDelete transaction state.
method generate_attach_opaque_data
Section titled âmethod generate_attach_opaque_dataâgenerate_attach_opaque_data() -> AttachOpaqueDataGenerate a new unique attach_opaque_data.
method generate_transaction_opaque_data
Section titled âmethod generate_transaction_opaque_dataâgenerate_transaction_opaque_data() -> TransactionOpaqueDataGenerate a new unique transaction_opaque_data.
method cleanup_old_entries
Section titled âmethod cleanup_old_entriesâcleanup_old_entries(max_age_days: float = 7.0) -> intRemove entries older than the specified age from all tables.
class ColumnStatistics
Section titled âclass ColumnStatisticsâDescription
Statistics for a single column in a table.
Workers provide these to help DuckDBâs optimizer make cost-based decisions (filter elimination, join reordering, etc.).
Attributes
attribute column_name
Section titled âattribute column_nameâstr
Name of the column these statistics describe.
attribute min
Section titled âattribute minâMinimum value as a typed PyArrow scalar (e.g., pa.scalar(0, pa.int64())),
or None if unknown.
attribute max
Section titled âattribute maxâMaximum value as a typed PyArrow scalar, or None if unknown.
Must have the same Arrow type as min.
attribute has_null
Section titled âattribute has_nullâbool
Whether the column contains any null values.
attribute has_not_null
Section titled âattribute has_not_nullâbool
Whether the column contains any non-null values.
attribute distinct_count
Section titled âattribute distinct_countâint | None
Approximate count of distinct values, or None if unknown.
attribute contains_unicode
Section titled âattribute contains_unicodeâbool | None
String/binary columns only â whether values contain non-ASCII
characters. None for non-string columns.
attribute max_string_length
Section titled âattribute max_string_lengthâint | None
String/binary columns only â maximum byte length of values.
None for non-string columns.
class CopyFromFormatInfo
Section titled âclass CopyFromFormatInfoâBases: CatalogObject, ArrowSerializableDataclass
Description
A custom COPY ... FROM format advertised by a VGI catalog.
The VGI DuckDB extension registers one DuckDB CopyFunction per advertised
format (into the system catalog, keyed by format_name) so users can run
COPY target FROM 'path' (FORMAT <format_name>, opt val, ...) and have a
worker function parse the source and stream rows into a local table. Discovery
is catalog-level via :meth:VgiProtocol.catalog_copy_from_formats; see the
C++ vgi_copy_from_impl.cpp and docs/copy_from.md.
Inherits comment and tags from :class:CatalogObject.
Attributes
attribute format_name
Section titled âattribute format_nameâstr
The FORMAT identifier users type. Lives in a single
global namespace shared with built-ins (csv/parquet/json)
and every other attached catalogâs formats â collisions are rejected
at ATTACH by the extension.
attribute handler
Section titled âattribute handlerâstr
Registered name of the worker function that performs the read.
attribute options
Section titled âattribute optionsâSerializedSchema
Serialized Arrow schema of the formatâs options, built from the
handlerâs Arg-annotated arguments (same encoding as
:attr:FunctionInfo.arguments); each fieldâs metadata carries the
option type / default / vgi_doc description. The reserved
file_path positional is excluded.
attribute direction
Section titled âattribute directionâstr
"from" | "to" | "both" â which COPY direction(s)
this format serves; surfaced so the C++ vgi_copy_formats()
diagnostic can split FROM vs TO and so registration wires the right
callbacks.
attribute description
Section titled âattribute descriptionâstr
Intrinsic documentation from the handlerâs
Meta.description.
attribute ordered
Section titled âattribute orderedâbool
COPY ⌠TO only â when true the worker requires rows in source
order, so the extension uses a single-threaded sink
(REGULAR_COPY_TO_FILE) instead of the default parallel sharded
write. Set via Meta.ordered = True on a CopyToFunction.
Ignored for readers.
Inherited members (2)
commentattribute ¡ from CatalogObjecttagsattribute ¡ from CatalogObject
function deserialize_column_statistics
Section titled âfunction deserialize_column_statisticsâdeserialize_column_statistics(data: bytes) -> list[ColumnStatistics]
Deserialize column statistics â the inverse of serialize_column_statistics.
Reads the sparse-union wire batch back into typed ColumnStatistics, so a client
can consume the bytes returned by catalog_table_column_statistics_get without
re-implementing the union layout. See
Client.table_column_statistics for the
wrapper that fetches and decodes in one call.
The optional cache_max_age_seconds travels in the IPC batchâs custom metadata
rather than in the statistics themselves; read it with deserialize_record_batch
if you need it.
class ForeignKeyDef
Section titled âclass ForeignKeyDefâDescription
A foreign key constraint definition.
Attributes
attribute columns
Section titled âattribute columnsâtuple[str, âŚ]
Column names in THIS table that form the FK.
attribute referenced_table
Section titled âattribute referenced_tableâstr
Name of the referenced table.
attribute referenced_columns
Section titled âattribute referenced_columnsâtuple[str, âŚ]
Column names in the referenced table.
attribute referenced_schema
Section titled âattribute referenced_schemaâstr | None
Schema of the referenced table. Defaults to None meaning same schema as this table.
class FunctionInfo
Section titled âclass FunctionInfoâBases: CatalogSchemaObject, ArrowSerializableDataclass
Description
Information about a function in a schema.
Attributes
attribute arguments
Section titled âattribute argumentsâSerializedSchema
The arguments as a serialized Apache arrow schema using
schema.serialize().to_pybytes().
attribute output_schema
Section titled âattribute output_schemaâSerializedSchema
The output schema as a serialized Apache arrow schema
using schema.serialize().to_pybytes().
attribute stability
Section titled âattribute stabilityâFunctionStability | None
Scalar function behavior field (None for non-scalar functions).
attribute null_handling
Section titled âattribute null_handlingâNullHandling | None
Scalar function behavior field (None for non-scalar functions).
attribute description
Section titled âattribute descriptionâstr
Intrinsic documentation from function metadata
(Meta.description). The user-settable comment (via COMMENT ON
FUNCTION) is inherited from the base object.
attribute examples
Section titled âattribute examplesâlist[CatalogExample]
Usage examples for the function.
attribute categories
Section titled âattribute categoriesâlist[str]
Category labels for the function.
attribute projection_pushdown
Section titled âattribute projection_pushdownâbool | None
Table-function capability (None for scalar functions).
attribute filter_pushdown
Section titled âattribute filter_pushdownâbool | None
Table-function capability (None for scalar functions).
attribute sampling_pushdown
Section titled âattribute sampling_pushdownâbool | None
Table-function capability (None for scalar functions).
attribute late_materialization
Section titled âattribute late_materializationâbool | None
True if the table participates in DuckDBâs
late-materialization optimizer (Meta.late_materialization). The
DuckDB extension only honours this when the table also exposes a
rowid virtual column plus filter/projection pushdown â see
GetScanFunctionImpl in the C++ vgi_table_entry.cpp.
attribute supported_expression_filters
Section titled âattribute supported_expression_filtersâlist[str]
Expression-filter classes the function can accept pushed down.
attribute order_preservation
Section titled âattribute order_preservationâOrderPreservation | None
Whether the function preserves input ordering.
attribute max_workers
Section titled âattribute max_workersâAnnotated[int | None, ArrowType(pa.int32())]
Maximum parallel workers. Uses ArrowType to specify int32 instead of the default int64.
attribute supports_batch_index
Section titled âattribute supports_batch_indexâbool
True if the function opts in to per-batch
vgi_batch_index tagging: the worker emits an integer partition id
in each Arrow batchâs KeyValueMetadata; the DuckDB extension threads
it through TableFunction::get_partition_data so ordered sinks
(BatchCollector, BatchInsert, BatchCopyToFile, Limit) can reassemble
parallel output in partition-id order. Opting in also skips the
FIXED_ORDER MaxThreads=1 clamp; the source stays parallel and the
sink does the ordering.
attribute partition_kind
Section titled âattribute partition_kindâPartition shape declared by the function over its
vgi.partition_column-annotated bind-schema fields. When
non-NOT_PARTITIONED, the DuckDB extension installs
TableFunction::get_partition_info returning the corresponding
TablePartitionInfo value so the planner can pick
PhysicalPartitionedAggregate for GROUP BY queries (today,
only SINGLE_VALUE_PARTITIONS materially changes planner
behavior). Per-column annotation lives in the bind schemaâs
field-level metadata â see vgi.schema_utils.partition_field.
attribute order_dependent
Section titled âattribute order_dependentâAggregate function field (future).
attribute distinct_dependent
Section titled âattribute distinct_dependentâAggregate function field (future).
attribute supports_window
Section titled âattribute supports_windowâbool
True if the aggregate implements the window() callback.
attribute streaming_partitioned
Section titled âattribute streaming_partitionedâbool
True if the aggregate opts into the
streaming-partitioned protocol â aggregate_streaming_open /
_chunk / _close. The DuckDB extensionâs optimizer rule may
rewrite eligible LogicalWindow nodes to use this path.
attribute has_finalize
Section titled âattribute has_finalizeâbool
True if a table-in-out function declares a finalize/finish
stage. The C++ extension uses this to conditionally register
in_out_function_final; DuckDB rejects LATERAL with correlated
input on functions that register a finalize callback.
attribute source_order_dependent
Section titled âattribute source_order_dependentâbool
Only meaningful when function_type == FunctionType.TABLE_BUFFERING (i.e. the function is registered
through the Sink+Source path). When true, the source phase is
single-threaded and finalize_state_ids drain in combine-returned
order. Default false enables parallel finalize.
attribute sink_order_dependent
Section titled âattribute sink_order_dependentâbool
Only meaningful when function_type == FunctionType.TABLE_BUFFERING. When true, the SINK phase runs
single-threaded â every process() call arrives in source order on one
worker. Mutually exclusive with requires_input_batch_index.
attribute requires_input_batch_index
Section titled âattribute requires_input_batch_indexâbool
Only meaningful when function_type == FunctionType.TABLE_BUFFERING. When true, the C++ Sink operator
declares RequiredPartitionInfo()=BatchIndex(); each process() RPC
carries a globally-unique monotonic batch_index from DuckDBâs source.
Workers can sort by it in combine() to reconstruct source order under
parallel ingest. Mutually exclusive with sink_order_dependent.
attribute input_from_args
Section titled âattribute input_from_argsâbool
True for a blended RowTransformFunction â its
positional args ARE its per-row input columns (real typed args, no
TABLE placeholder), so one registration serves the literal /
column / LATERAL call shapes. Set from RowTransformFunction
subclassing; the C++ extension reads it to enter the in-out
registration branch with real-typed args and drive the literal
single-row scan-mode.
attribute required_settings
Section titled âattribute required_settingsâlist[str]
Settings required by the function.
attribute required_secrets
Section titled âattribute required_secretsâlist[SecretLookupEntry]
Secrets required by the function (each entry has secret_type, optional secret_name, optional scope).
Inherited members (4)
commentattribute ¡ from CatalogObjecttagsattribute ¡ from CatalogObjectnameattribute ¡ from CatalogSchemaObjectschema_nameattribute ¡ from CatalogSchemaObject
class FunctionType
Section titled âclass FunctionTypeâBases: Enum
Description
The type of function in a schema.
Attributes
attribute TABLE_BUFFERING
Section titled âattribute TABLE_BUFFERINGâA table-buffering (table-in-out) function.
class Index
Section titled âclass IndexâDescription
Declarative index definition.
Immutable.
Attributes
attribute expressions
Section titled âattribute expressionsâtuple[str, âŚ]
SQL expression strings or column names defining the index. For column-based indexes: (âcol_aâ, âcol_bâ) For expression indexes: (âlower(col_a)â, âcol_b + 1â)
attribute index_type
Section titled âattribute index_typeâstr
The index type (e.g., ââ for default).
attribute constraint_type
Section titled âattribute constraint_typeâNONE for regular, UNIQUE for unique indexes.
Methods
method to_index_info
Section titled âmethod to_index_infoâto_index_info(schema_name: str) -> IndexInfoConvert to IndexInfo for catalog response.
class IndexConstraintType
Section titled âclass IndexConstraintTypeâBases: Enum
Description
The constraint type of an index.
Attributes
class IndexInfo
Section titled âclass IndexInfoâBases: CatalogSchemaObject, ArrowSerializableDataclass
Description
Information about an index in a schema.
Attributes
attribute table_name
Section titled âattribute table_nameâstr
The name of the table this index is on.
attribute index_type
Section titled âattribute index_typeâstr
The index type string (e.g., âARTâ, or empty for default).
attribute constraint_type
Section titled âattribute constraint_typeâThe constraint enforcement type (NONE, UNIQUE, PRIMARY).
attribute expressions
Section titled âattribute expressionsâlist[str]
SQL expression strings defining the indexed expressions. For column-based indexes, these are column references (e.g., âcol_aâ). For expression indexes, these are arbitrary SQL (e.g., âlower(col_a)â).
attribute options
Section titled âattribute optionsâdict[str, str]
Key-value index options (WITH clause).
Inherited members (4)
commentattribute ¡ from CatalogObjecttagsattribute ¡ from CatalogObjectnameattribute ¡ from CatalogSchemaObjectschema_nameattribute ¡ from CatalogSchemaObject
class Macro
Section titled âclass MacroâDescription
Declarative macro definition.
Attributes
attribute macro_type
Section titled âattribute macro_typeâWhether this is a scalar or table macro.
attribute parameters
Section titled âattribute parametersâlist[str]
Ordered list of parameter names.
attribute parameter_default_values
Section titled âattribute parameter_default_valuesâpa.RecordBatch | None
One-row RecordBatch where columns are parameter
names and values are typed defaults. None if no defaults.
Example: pa.RecordBatch.from_pydict({âbâ: [5]}) for b := 5.
attribute parameter_docs
Section titled âattribute parameter_docsâdict[str, str]
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), so the DuckDB extensionâs
vgi_function_arguments() can surface them. Empty/default = no docs.
attribute definition
Section titled âattribute definitionâstr
SQL expression (scalar) or query (table).
Methods
method to_macro_info
Section titled âmethod to_macro_infoâto_macro_info(schema_name: str) -> MacroInfoConvert to MacroInfo for catalog response.
class MacroInfo
Section titled âclass MacroInfoâBases: CatalogSchemaObject, ArrowSerializableDataclass
Description
Information about a macro in a schema.
Attributes
attribute macro_type
Section titled âattribute macro_typeâWhether this is a scalar or table macro.
attribute parameters
Section titled âattribute parametersâlist[str]
Ordered list of parameter names.
attribute parameter_default_values
Section titled âattribute parameter_default_valuesâAnnotated[pa.RecordBatch | None, ArrowType(pa.binary())]
One-row RecordBatch where column names are parameter
names and values are typed defaults. None if no defaults.
Serialized as IPC bytes over the wire.
attribute definition
Section titled âattribute definitionâstr
The SQL expression (scalar) or query (table).
attribute arguments_schema
Section titled âattribute arguments_schemaâAnnotated[pa.Schema | None, ArrowType(pa.binary())]
Optional Arrow schema (serialized as IPC bytes) with one
nullable field per parameter, in parameters order. Each fieldâs type
is the parameterâs default value type when known (else null), and the
vgi_doc field metadata key carries the parameterâs description (UTF-8,
presence-only â omitted when undocumented). Mirrors the per-argument doc
channel functions expose via FunctionInfo.arguments. None means the
worker did not supply per-parameter docs (older workers); the extension
falls back to parameters for names. Built with
vgi.argument_spec.macro_arguments_schema.
Inherited members (4)
commentattribute ¡ from CatalogObjecttagsattribute ¡ from CatalogObjectnameattribute ¡ from CatalogSchemaObjectschema_nameattribute ¡ from CatalogSchemaObject
class MacroType
Section titled âclass MacroTypeâBases: Enum
Description
The type of macro in a schema.
Attributes
class OnConflict
Section titled âclass OnConflictâBases: Enum
Description
Behavior when a conflict occurs during creation of an object.
Attributes
attribute REPLACE
Section titled âattribute REPLACEâReplace the existing object if it already exists.
class ReadOnlyCatalogInterface
Section titled âclass ReadOnlyCatalogInterfaceâBases: CatalogInterface
Description
A read-only catalog interface that does not support DDL operations.
This is a convenience base class for catalogs that only support reading metadata and data, not creating or modifying objects.
There are two ways to use this class:
-
Subclass and implement abstract methods:
- catalogs() - List available catalogs
- catalog_attach() - Attach to a catalog
- schema_get() - Get schema information
- table_get() - Get table information (return None for function-only catalogs)
- view_get() - Get view information (return None for function-only catalogs)
-
Use with functions list (simpler for function-only catalogs): Set the
functionsclass attribute to expose VGI functions:- catalog_name - Name of the catalog (default: âfunctionsâ)
- functions - List of function classes to expose in the âmainâ schema
This provides automatic implementations of catalogs(), catalog_attach(), schema_get(), table_get(), view_get(), and schema_contents().
Optional methods that can be overridden:
- catalog_detach() - Custom detach logic
- schemas() - Custom schema listing (default returns âmainâ)
- schema_contents() - List schema contents
- table_scan_function_get() - Get scan function for tables
All DDL operations (create, drop, rename, modify) will raise
CatalogReadOnlyError.
Attributes
attribute supports_transactions
Section titled âattribute supports_transactionsâAlways False â read-only catalogs do not
support transactions.
attribute catalog_version_frozen
Section titled âattribute catalog_version_frozenâAlways True â the catalog version never
changes.
attribute catalog_name
Section titled âattribute catalog_nameâstr
Name of the catalog exposed when using the functions-list
mode (default "functions").
attribute functions
Section titled âattribute functionsâlist[type]
Function classes to expose in the "main" schema.
attribute settings
Section titled âattribute settingsâlist[SettingSpec]
DuckDB setting specs the catalog declares.
attribute secret_types
Section titled âattribute secret_typesâlist[SecretTypeSpec]
Secret type specs the catalog declares.
attribute attach_option_specs
Section titled âattribute attach_option_specsâlist[AttachOptionSpec]
Attach option specs accepted at ATTACH time.
attribute attach_catalogs
Section titled âattribute attach_catalogsâlist[AttachCatalogInfo]
Companion catalogs (lakehouse federation) the client should ATTACH when this catalog attaches.
attribute catalog
Section titled âattribute catalogâCatalog | None
Optional declarative Catalog object describing the
catalogâs schemas, tables, and views.
attribute catalog_create
Section titled âattribute catalog_createâDDL stub that raises [CatalogReadOnlyError`](/vgi/docs/python/api/vgi-exceptions/#vgi.exceptions.CatalogReadOnlyError).
attribute catalog_drop
Section titled âattribute catalog_dropâDDL stub that raises [CatalogReadOnlyError`](/vgi/docs/python/api/vgi-exceptions/#vgi.exceptions.CatalogReadOnlyError).
attribute catalog_transaction_begin
Section titled âattribute catalog_transaction_beginâDDL stub that raises [CatalogReadOnlyError`](/vgi/docs/python/api/vgi-exceptions/#vgi.exceptions.CatalogReadOnlyError).
attribute catalog_transaction_commit
Section titled âattribute catalog_transaction_commitâDDL stub that raises [CatalogReadOnlyError`](/vgi/docs/python/api/vgi-exceptions/#vgi.exceptions.CatalogReadOnlyError).
attribute catalog_transaction_rollback
Section titled âattribute catalog_transaction_rollbackâDDL stub that raises [CatalogReadOnlyError`](/vgi/docs/python/api/vgi-exceptions/#vgi.exceptions.CatalogReadOnlyError).
attribute schema_create
Section titled âattribute schema_createâDDL stub that raises [CatalogReadOnlyError`](/vgi/docs/python/api/vgi-exceptions/#vgi.exceptions.CatalogReadOnlyError).
attribute schema_drop
Section titled âattribute schema_dropâDDL stub that raises [CatalogReadOnlyError`](/vgi/docs/python/api/vgi-exceptions/#vgi.exceptions.CatalogReadOnlyError).
attribute table_create
Section titled âattribute table_createâDDL stub that raises [CatalogReadOnlyError`](/vgi/docs/python/api/vgi-exceptions/#vgi.exceptions.CatalogReadOnlyError).
attribute table_drop
Section titled âattribute table_dropâDDL stub that raises [CatalogReadOnlyError`](/vgi/docs/python/api/vgi-exceptions/#vgi.exceptions.CatalogReadOnlyError).
attribute table_comment_set
Section titled âattribute table_comment_setâDDL stub that raises [CatalogReadOnlyError`](/vgi/docs/python/api/vgi-exceptions/#vgi.exceptions.CatalogReadOnlyError).
attribute table_column_comment_set
Section titled âattribute table_column_comment_setâDDL stub that raises [CatalogReadOnlyError`](/vgi/docs/python/api/vgi-exceptions/#vgi.exceptions.CatalogReadOnlyError).
attribute table_rename
Section titled âattribute table_renameâDDL stub that raises [CatalogReadOnlyError`](/vgi/docs/python/api/vgi-exceptions/#vgi.exceptions.CatalogReadOnlyError).
attribute table_column_add
Section titled âattribute table_column_addâDDL stub that raises [CatalogReadOnlyError`](/vgi/docs/python/api/vgi-exceptions/#vgi.exceptions.CatalogReadOnlyError).
attribute table_column_drop
Section titled âattribute table_column_dropâDDL stub that raises [CatalogReadOnlyError`](/vgi/docs/python/api/vgi-exceptions/#vgi.exceptions.CatalogReadOnlyError).
attribute table_column_rename
Section titled âattribute table_column_renameâDDL stub that raises [CatalogReadOnlyError`](/vgi/docs/python/api/vgi-exceptions/#vgi.exceptions.CatalogReadOnlyError).
attribute table_column_default_set
Section titled âattribute table_column_default_setâDDL stub that raises [CatalogReadOnlyError`](/vgi/docs/python/api/vgi-exceptions/#vgi.exceptions.CatalogReadOnlyError).
attribute table_column_default_drop
Section titled âattribute table_column_default_dropâDDL stub that raises [CatalogReadOnlyError`](/vgi/docs/python/api/vgi-exceptions/#vgi.exceptions.CatalogReadOnlyError).
attribute table_column_type_change
Section titled âattribute table_column_type_changeâDDL stub that raises [CatalogReadOnlyError`](/vgi/docs/python/api/vgi-exceptions/#vgi.exceptions.CatalogReadOnlyError).
attribute table_not_null_drop
Section titled âattribute table_not_null_dropâDDL stub that raises [CatalogReadOnlyError`](/vgi/docs/python/api/vgi-exceptions/#vgi.exceptions.CatalogReadOnlyError).
attribute table_not_null_set
Section titled âattribute table_not_null_setâDDL stub that raises [CatalogReadOnlyError`](/vgi/docs/python/api/vgi-exceptions/#vgi.exceptions.CatalogReadOnlyError).
attribute view_create
Section titled âattribute view_createâDDL stub that raises [CatalogReadOnlyError`](/vgi/docs/python/api/vgi-exceptions/#vgi.exceptions.CatalogReadOnlyError).
attribute view_drop
Section titled âattribute view_dropâDDL stub that raises [CatalogReadOnlyError`](/vgi/docs/python/api/vgi-exceptions/#vgi.exceptions.CatalogReadOnlyError).
attribute view_rename
Section titled âattribute view_renameâDDL stub that raises [CatalogReadOnlyError`](/vgi/docs/python/api/vgi-exceptions/#vgi.exceptions.CatalogReadOnlyError).
attribute view_comment_set
Section titled âattribute view_comment_setâDDL stub that raises [CatalogReadOnlyError`](/vgi/docs/python/api/vgi-exceptions/#vgi.exceptions.CatalogReadOnlyError).
attribute macro_create
Section titled âattribute macro_createâDDL stub that raises [CatalogReadOnlyError`](/vgi/docs/python/api/vgi-exceptions/#vgi.exceptions.CatalogReadOnlyError).
attribute macro_drop
Section titled âattribute macro_dropâDDL stub that raises [CatalogReadOnlyError`](/vgi/docs/python/api/vgi-exceptions/#vgi.exceptions.CatalogReadOnlyError).
attribute index_create
Section titled âattribute index_createâDDL stub that raises [CatalogReadOnlyError`](/vgi/docs/python/api/vgi-exceptions/#vgi.exceptions.CatalogReadOnlyError).
attribute index_drop
Section titled âattribute index_dropâDDL stub that raises [CatalogReadOnlyError`](/vgi/docs/python/api/vgi-exceptions/#vgi.exceptions.CatalogReadOnlyError).
Methods
method catalogs
Section titled âmethod catalogsâcatalogs() -> list[CatalogInfo]Return the list of available catalogs.
Default discovery record carries just the catalog name â subclasses that want to advertise version metadata should override.
method catalog_attach
Section titled âmethod catalog_attachâcatalog_attach(
*,
name: str,
options: dict[str, Any],
data_version_spec: str | None,
implementation_version: str | None,
ctx: CallContext | None = None,
) -> CatalogAttachResultAttach to the catalog. Version constraints are ignored by default.
method schemas
Section titled âmethod schemasâschemas(
*,
attach_opaque_data: AttachOpaqueData,
transaction_opaque_data: TransactionOpaqueData | None,
) -> list[SchemaInfo]Get a list of schemas for the given attach_opaque_data.
method schema_get
Section titled âmethod schema_getâschema_get(
*,
attach_opaque_data: AttachOpaqueData,
transaction_opaque_data: TransactionOpaqueData | None,
name: str,
) -> SchemaInfo | NoneGet information about a schema (case-insensitive lookup).
method table_get
Section titled âmethod table_getâtable_get(
*,
attach_opaque_data: AttachOpaqueData,
transaction_opaque_data: TransactionOpaqueData | None,
schema_name: str,
name: str,
at_unit: str | None = None,
at_value: str | None = None,
) -> TableInfo | NoneGet information about a table (case-insensitive lookup).
When at_unit / at_value are provided, the default implementation
returns the same table info (no schema evolution). Override this method
to return version-specific schemas for time-travel queries.
method view_get
Section titled âmethod view_getâview_get(
*,
attach_opaque_data: AttachOpaqueData,
transaction_opaque_data: TransactionOpaqueData | None,
schema_name: str,
name: str,
) -> ViewInfo | NoneGet information about a view (case-insensitive lookup).
method macro_get
Section titled âmethod macro_getâmacro_get(
*,
attach_opaque_data: AttachOpaqueData,
transaction_opaque_data: TransactionOpaqueData | None,
schema_name: str,
name: str,
) -> MacroInfo | NoneGet information about a macro (case-insensitive lookup).
method index_get
Section titled âmethod index_getâindex_get(
*,
attach_opaque_data: AttachOpaqueData,
transaction_opaque_data: TransactionOpaqueData | None,
schema_name: str,
name: str,
) -> IndexInfo | NoneGet information about an index (case-insensitive lookup).
method table_column_statistics_get
Section titled âmethod table_column_statistics_getâtable_column_statistics_get(
*,
attach_opaque_data: AttachOpaqueData,
transaction_opaque_data: TransactionOpaqueData | None,
schema_name: str,
name: str,
) -> TableColumnStatisticsResult | NoneGet column statistics from the Table descriptorâs statistics dict.
Automatically resolves plain Python values to typed PyArrow scalars using the columnâs Arrow type from the table schema. Override this method for dynamic or computed statistics.
method table_scan_function_get
Section titled âmethod table_scan_function_getâtable_scan_function_get(
*,
attach_opaque_data: AttachOpaqueData,
transaction_opaque_data: TransactionOpaqueData | None,
schema_name: str,
name: str,
at_unit: str | None,
at_value: str | None,
) -> ScanFunctionResultGet scan function for a table.
For function-backed tables (Table.function is set), automatically returns
a ScanFunctionResult that invokes the linked function.
For tables with explicit columns, override this method in your Worker to provide scan functions.
method table_insert_function_get
Section titled âmethod table_insert_function_getâtable_insert_function_get(
*,
attach_opaque_data: AttachOpaqueData,
transaction_opaque_data: TransactionOpaqueData | None,
schema_name: str,
name: str,
writable_branch_function_name: str | None = None,
) -> ScanFunctionResultGet insert function for a table.
method table_update_function_get
Section titled âmethod table_update_function_getâtable_update_function_get(
*,
attach_opaque_data: AttachOpaqueData,
transaction_opaque_data: TransactionOpaqueData | None,
schema_name: str,
name: str,
) -> ScanFunctionResultGet update function for a table.
method table_delete_function_get
Section titled âmethod table_delete_function_getâtable_delete_function_get(
*,
attach_opaque_data: AttachOpaqueData,
transaction_opaque_data: TransactionOpaqueData | None,
schema_name: str,
name: str,
) -> ScanFunctionResultGet delete function for a table.
method schema_contents
Section titled âmethod schema_contentsâschema_contents(
*,
attach_opaque_data: AttachOpaqueData,
transaction_opaque_data: TransactionOpaqueData | None,
name: str,
type: SchemaObjectType,
) -> Sequence[TableInfo | ViewInfo | FunctionInfo | MacroInfo | IndexInfo]List contents of a schema.
Returns tables, views, functions, macros, or indexes based on the type parameter. Uses case-insensitive schema name lookup.
method copy_from_formats
Section titled âmethod copy_from_formatsâcopy_from_formats(
*,
attach_opaque_data: AttachOpaqueData,
transaction_opaque_data: TransactionOpaqueData | None,
) -> list[CopyFromFormatInfo]Advertise every custom COPY format registered in this catalog.
Introspects the catalogâs function list for
:class:vgi.copy_from_function.CopyFromFunction (direction='from') and
:class:vgi.copy_to_function.CopyToFunction (direction='to') subclasses
and converts each into a :class:CopyFromFormatInfo. (The RPC name is
historical; it returns all directions, distinguished by direction.)
The option schema reuses the same argument serialization as
:meth:_function_to_info, so option types / defaults / doc descriptions
surface identically to vgi_function_arguments().
Inherited members (5)
interface_feature_flagsattribute ¡ from CatalogInterface â Get the feature flags supported by thisCatalogInterface.loggable_attach_optionsmethod ¡ from CatalogInterface â Return a redacted view of attach/create options safe for logs and Sentry breadcrumbs.catalog_detachmethod ¡ from CatalogInterface â Detach from the catalog with the given attach_opaque_data.catalog_versionmethod ¡ from CatalogInterface â Get the current catalog version for the given attach_opaque_data and transaction_opaque_data.table_scan_branches_getmethod ¡ from CatalogInterface â Get the list of scan branches for a multi-source table.
class ScanBranch
Section titled âclass ScanBranchâDescription
One physical source backing a multi-branch scan.
A branch is one of two kinds:
- Function branch (the default) â
function_namenames a DuckDB table function bound withpositional_arguments/named_arguments. - Catalog-table branch â
function_nameis empty ("") andsource_tableis set; the branch scans the base tablesource_catalog.source_schema.source_tablein an attached catalog (typically an :class:AttachCatalogInfocompanion, e.g. a DuckLake table). The extension binds it via the catalogâs own scan function, so a companionâs snapshot/pruning semantics are honored.
The discriminator is simply âsource_table present â catalog-table kindâ.
Attributes
attribute function_name
Section titled âattribute function_nameâstr
The DuckDB function to call for a function branch
(e.g., "read_parquet", "iceberg_scan", or a VGI
table function). The C++ rewriter resolves this name against
DuckDBâs function catalog and binds it at optimize time. Empty
string for a catalog-table branch.
attribute positional_arguments
Section titled âattribute positional_argumentsâPositional arguments as PyArrow scalars,
passed through to the functionâs bind.
attribute named_arguments
Section titled âattribute named_argumentsâNamed arguments as PyArrow scalars.
attribute branch_filter
Section titled âattribute branch_filterâstr | None
Optional SQL expression text (parsed by DuckDBâs
parser, bound against the branchâs bound column list). The
rewriter ANDâs this into every scan of this branch BEFORE
filter pushdown, so the branch only ever sees rows in its
declared scope. Used to make overlapping physical sources
(Kafka 7d retention + Iceberg nightly batches with ~24h
overlap) non-overlapping at scan time, without changing the
worker code. None means unconstrained.
attribute writable
Section titled âattribute writableâbool
Declares this branch as the INSERT target for the multi-branch table. At most one branch per table may set this true (enforced at catalog-load by the C++ extension â multiple writable arms would violate DuckDBâs single- writable-catalog-per-transaction rule). When no branch is writable, the table is read-only. UPDATE/DELETE/MERGE remain refused on multi-branch tables regardless of this flag; the contract is INSERT-only until cross-arm semantics have customer-driven evidence.
attribute source_catalog
Section titled âattribute source_catalogâstr | None
Catalog-table branch only â the attached catalog name
(matches an :attr:AttachCatalogInfo.alias). None for function
branches.
attribute source_schema
Section titled âattribute source_schemaâstr | None
Catalog-table branch only â the schema of the source
table. None for function branches.
attribute source_table
Section titled âattribute source_tableâstr | None
Catalog-table branch only â the base table name; its
presence selects the catalog-table kind. None for function
branches.
attribute ARROW_SCHEMA
Section titled âattribute ARROW_SCHEMAâArrow IPC schema used to (de)serialize this branch over the wire.
Methods
method to_row_dict
Section titled âmethod to_row_dictâto_row_dict() -> dict[str, Any]Convert to a dictionary for batch construction.
Arguments are serialized as nested Arrow IPC bytes (same trick as
:class:ScanFunctionResult).
method serialize
Section titled âmethod serializeâserialize() -> bytesSerialize to Arrow IPC bytes (1-row batch using ARROW_SCHEMA).
method deserialize
Section titled âmethod deserializeâdeserialize(batch: pa.RecordBatch) -> SelfDeserialize from a 1-row Arrow RecordBatch.
class ScanBranchesResult
Section titled âclass ScanBranchesResultâDescription
Result from getting the list of scan branches for a multi-branch table.
The result tells the VGI DuckDB extension which DuckDB function(s) to call to obtain the data for the table. Each branch is bound independently and the rewriter unions their output.
Attributes
attribute branches
Section titled âattribute branchesâlist[ScanBranch]
One ScanBranch per physical source. Order is meaningful
for stable diagnostic output (vgi_table_branches()) but not
for query semantics (UNION ALL is unordered).
attribute required_extensions
Section titled âattribute required_extensionsâlist[str]
Union of all DuckDB extensions needed across all
branches (e.g., ["iceberg", "httpfs"]). The C++ side auto-loads
unloaded entries before running the rewrite; missing extensions
surface the existing extension-load diagnostic. Hoisted to the
top level so workers donât repeat "iceberg" on every branch
that uses it.
attribute ARROW_SCHEMA
Section titled âattribute ARROW_SCHEMAâArrow IPC schema used to (de)serialize this result over the wire.
Methods
method to_row_dict
Section titled âmethod to_row_dictâto_row_dict() -> dict[str, Any]Convert to a dictionary for batch construction.
method serialize
Section titled âmethod serializeâserialize() -> bytesSerialize to Arrow IPC bytes (1-row batch using ARROW_SCHEMA).
method deserialize
Section titled âmethod deserializeâdeserialize(batch: pa.RecordBatch) -> SelfDeserialize from a 1-row Arrow RecordBatch.
Empty branches list is rejected â workers must return at least one branch. (See the design memoâs âloud at attachâ rule.)
class ScanFunctionResult
Section titled âclass ScanFunctionResultâDescription
Result from getting a table scan function.
This result tells the VGI DuckDB extension which DuckDB function to call to obtain the data for a table. This enables catalogs to delegate scanning to any DuckDB function (e.g., read_parquet, iceberg_scan, or a custom VGI table function) with appropriate arguments.
Attributes
attribute function_name
Section titled âattribute function_nameâstr
The DuckDB function to call (e.g., âread_parquetâ).
attribute positional_arguments
Section titled âattribute positional_argumentsâPositional arguments as PyArrow scalars.
attribute named_arguments
Section titled âattribute named_argumentsâNamed arguments as PyArrow scalars.
attribute required_extensions
Section titled âattribute required_extensionsâlist[str]
DuckDB extensions to load before calling.
attribute ARROW_SCHEMA
Section titled âattribute ARROW_SCHEMAâArrow IPC schema used to (de)serialize this result over the wire.
Methods
method to_row_dict
Section titled âmethod to_row_dictâto_row_dict() -> dict[str, Any]Convert to a dictionary for batch construction.
The arguments field is serialized as nested Arrow IPC bytes.
method serialize
Section titled âmethod serializeâserialize() -> bytesSerialize to Arrow IPC bytes.
method deserialize
Section titled âmethod deserializeâdeserialize(batch: pa.RecordBatch) -> SelfDeserialize from Arrow RecordBatch.
class Schema
Section titled âclass SchemaâDescription
Declarative schema definition grouping tables, views, functions, macros, and indexes.
Attributes
attribute functions
Section titled âattribute functionsâSequence[type[Function]]
Sequence of Function classes (scalar, table, or aggregate).
attribute indexes
Section titled âattribute indexesâSequence[Index]
Sequence of Index definitions.
Methods
method to_schema_info
Section titled âmethod to_schema_infoâto_schema_info(attach_opaque_data: AttachOpaqueData) -> SchemaInfoConvert to SchemaInfo for catalog response.
Populates estimated_object_count from the declared population so
the C++ extensionâs eager-load gate can choose between bulk
LoadEntries and per-name single-entry RPCs without an extra round
trip. Functions are partitioned by get_metadata().function_type
into the three keys (scalar_function, aggregate_function,
table_function) so DuckDBâs per-type catalog probes (a name
lookup walks scalar â aggregate â table) skip the bulk RPC for any
category the schema doesnât populate.
Zero counts are load-bearing. Empty declarative collections
(e.g. views=()) emit 0 here, which the C++ client treats as
a hard guarantee and uses to skip the corresponding bulk + per-name
RPCs entirely. Do not âoptimizeâ this into omitting empty keys â
absence reads as count=1 (unknown), suppressing the RPC bypass.
class SchemaInfo
Section titled âclass SchemaInfoâBases: CatalogObject, ArrowSerializableDataclass
Description
Information about a schema in a catalog.
Attributes
attribute attach_opaque_data
Section titled âattribute attach_opaque_dataâAttachOpaqueData
The unique id for the attached catalog.
attribute estimated_object_count
Section titled âattribute estimated_object_countâdict[str, int] | None
Approximate population per object kind, keyed by
the same names the C++ extension uses for its set-cache
instrumentation: "table", "view", "scalar_function",
"aggregate_function", "table_function", "macro",
"index". Used by the client to pick between bulk LoadEntries
and per-name single-entry RPCs. Workers may omit the field entirely
or any individual key â the client treats absent counts as 1, so
unspecified populations bias toward eager bulk-load.
The value 0 is a hard guarantee, not an estimate. When a count
is exactly 0 the client skips the corresponding
catalog_schema_contents_* bulk RPC entirely and short-circuits
per-name lookups (catalog_table_get / catalog_view_get /
catalog_index_get). If a worker reports 0 for a kind that
actually has entries, SELECT ⌠FROM s.x silently returns ânot
foundâ â only declare 0 for kinds the worker knows are empty in its
current view of the schema. Cross-session DDL on the same catalog
(another connection creating a view in a schema this connection has
cached as zero-views) is handled the same way as any other stale
catalog cache: vgi_clear_cache() or re-attach. Time-travel
AT-clause queries do not honor the bypass â they always issue the
per-name RPC because a historical version may have had entries the
current view does not.
Inherited members (2)
commentattribute ¡ from CatalogObjecttagsattribute ¡ from CatalogObject
class SchemaObjectType
Section titled âclass SchemaObjectTypeâBases: Enum
Description
The type of object that can exist within a schema.
Used to filter results from schema_contents().
Attributes
class SecretTypeSpec
Section titled âclass SecretTypeSpecâDescription
Specification for a custom secret type registered at ATTACH.
Defines the secret type name, description, and parameter schema. The schema is a standard Arrow schema where each field represents a secret parameter (key name -> value type). Fields that should be redacted in SHOW SECRETS are marked with {âredactâ: âtrueâ} in their Arrow field metadata.
Example
SecretTypeSpec(- name=âvgi_exampleâ, description=âExample VGI secret for testingâ, schema=pa.schema([ pa.field(âsecret_stringâ, pa.string(), metadata={âredactâ: âtrueâ}), pa.field(âapi_keyâ, pa.string(), metadata={âredactâ: âtrueâ}), pa.field(âportâ, pa.int32()), pa.field(âuse_sslâ, pa.bool_()), pa.field(âtimeoutâ, pa.float64()), ]),
Attributes
attribute schema
Section titled âattribute schemaâArrow schema defining the secretâs key-value parameters.
attribute ARROW_SCHEMA
Section titled âattribute ARROW_SCHEMAâArrow IPC schema used to (de)serialize this spec over the wire.
Methods
method serialize
Section titled âmethod serializeâserialize() -> bytesSerialize to Arrow IPC bytes.
method deserialize
Section titled âmethod deserializeâdeserialize(batch: pa.RecordBatch) -> SelfDeserialize from Arrow RecordBatch.
function serialize_column_statistics
Section titled âfunction serialize_column_statisticsâserialize_column_statistics(
stats: list[ColumnStatistics],
cache_max_age_seconds: int | None = None,
) -> bytes
Serialize column statistics into a single RecordBatch with sparse union min/max.
The min and max columns use an Arrow sparse union whose child types
are the distinct column types present in stats. This keeps everything in
a single IPC stream regardless of how many column types the table has.
class Setting
Section titled âclass SettingâBases: _DescriptorBase
Description
Descriptor for declarative setting definitions using Annotated.
Use with Annotated type hints to declare settings in a Workerâs Settings class.
The Arrow type is resolved from the base type in the Annotated hint. See
_DescriptorBase (in vgi.catalog._descriptor_spec) for the
desc and arrow_type attributes.
Inherited members (3)
descattribute ¡ from _DescriptorBasearrow_typeattribute ¡ from _DescriptorBaseextra_spec_kwargsmethod ¡ from _DescriptorBase â Extra keyword arguments this descriptor passes to its spec factory.
class SettingSpec
Section titled âclass SettingSpecâBases: _SpecBase
Description
Extracted setting metadata for catalog serialization.
This is the resolved form of a Setting, with all types inferred and
ready for serialization. See _SpecBase (in vgi.catalog._descriptor_spec)
for the field and wire-format definition.
Inherited members (7)
nameattribute ¡ from _SpecBasedescattribute ¡ from _SpecBasetypeattribute ¡ from _SpecBasedefaultattribute ¡ from _SpecBaseARROW_SCHEMAattribute ¡ from _SpecBaseserializemethod ¡ from _SpecBase â Serialize to Arrow IPC bytes.deserializemethod ¡ from _SpecBase â Deserialize from Arrow RecordBatch.
class Sql
Section titled âclass SqlâBases: str
Description
A raw SQL expression, passed through verbatim as a default value.
Use this when the default is a SQL expression rather than a Python literal:
defaults={"created_at": Sql("current_timestamp")}class Table
Section titled âclass TableâDescription
Declarative table definition.
Immutable. Can be defined in two ways:
- Explicit columns: Provide
columnsschema directly. - Function-backed: Provide
functionreference â the schema is derived by callingbind()on the function class. If the function requires arguments, supply them viaarguments.
Attributes
attribute columns
Section titled âattribute columnsâExplicit PyArrow schema (mutually exclusive with function).
attribute function
Section titled âattribute functionâtype[TableFunctionGenerator[Any, Any]] | None
TableFunctionGenerator class to derive schema from
(mutually exclusive with columns).
attribute arguments
Section titled âattribute argumentsâArguments | None
Arguments to pass when calling bind() on a
function-backed table. Required when the function has
mandatory parameters.
attribute supports_time_travel
Section titled âattribute supports_time_travelâbool
Whether this table supports time-travel (AT-clause) queries.
attribute insert_function
Section titled âattribute insert_functionâtype[TableInOutGenerator[Any, Any]] | None
TableInOutGenerator class backing INSERT. None
means INSERT is unsupported.
attribute update_function
Section titled âattribute update_functionâtype[TableInOutGenerator[Any, Any]] | None
TableInOutGenerator class backing UPDATE. Requires
a scan function to provide row IDs. None means UPDATE is
unsupported.
attribute delete_function
Section titled âattribute delete_functionâtype[TableInOutGenerator[Any, Any]] | None
TableInOutGenerator class backing DELETE. Requires
a scan function to provide row IDs. None means DELETE is
unsupported.
attribute not_null
Section titled âattribute not_nullâtuple[str, âŚ]
Tuple of column names with NOT NULL constraints.
attribute unique
Section titled âattribute uniqueâtuple[tuple[str, âŚ], âŚ]
Tuple of column name tuples for UNIQUE constraints.
attribute check
Section titled âattribute checkâtuple[str, âŚ]
Tuple of SQL expressions for CHECK constraints.
attribute primary_key
Section titled âattribute primary_keyâtuple[tuple[str, âŚ], âŚ]
Tuple of column-name tuples forming the primary key. At most one primary-key constraint is allowed.
attribute foreign_key
Section titled âattribute foreign_keyâtuple[ForeignKeyDef, âŚ]
Tuple of ForeignKeyDef foreign-key constraints.
attribute defaults
Section titled âattribute defaultsâdict[str, DefaultValue]
Dict mapping column names to default values. Accepts
Python literals (str, int, float, bool, None) which are
auto-converted, or SqlExpression for raw SQL.
attribute generated_columns
Section titled âattribute generated_columnsâdict[str, str]
Dict mapping column names to SQL expressions for generated (virtual) columns. Generated columns are computed on read by DuckDB and are mutually exclusive with defaults.
attribute column_comments
Section titled âattribute column_commentsâdict[str, str]
Dict mapping column names to comment strings.
Comments are transported as Arrow field metadata and visible
via duckdb_columns() in DuckDB.
attribute required_filters
Section titled âattribute required_filtersâtuple[tuple[str, âŚ], âŚ]
Required WHERE-filter groups in conjunctive normal
form â an AND (outer tuple) of OR-groups (inner tuples) 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 paths has a
filter; every group must be satisfied. So
(("accession_number",), ("ticker", "cik")) means âaccession_number
AND one of (ticker, cik)â; a single-path group (("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. Satisfaction is prefix-based: a present
filter on a shorter path satisfies any required path it is a prefix of
(a whole-struct filter on bbox satisfies all of bbox.xmin /
.xmax / .ymin / .ymax). The VGI DuckDB extensionâs
optimizer pass consults this at bind time and throws
BinderException listing any unsatisfied groups.
attribute statistics
Section titled âattribute statisticsâdict[str, ColumnStatisticsInput]
Mapping of column name to ColumnStatisticsInput
providing inlined column statistics for the optimizer.
attribute statistics_cache_max_age_seconds
Section titled âattribute statistics_cache_max_age_secondsâint | None
How long clients may cache the inlined
statistics, in seconds. None means cache indefinitely.
attribute cardinality_estimate
Section titled âattribute cardinality_estimateâint | None
Optional inlined cardinality. When set, the C++
extension uses these values directly and skips the per-bind
table_function_cardinality RPC. Use for read-only or
slow-changing tables. Leave both this and cardinality_max as
None to keep the existing per-bind RPC behavior.
attribute cardinality_max
Section titled âattribute cardinality_maxâint | None
Optional inlined maximum cardinality. Same caching
contract as cardinality_estimate.
attribute inline_bind
Section titled âattribute inline_bindâbool
Opt into pre-binding the function during
schema_contents and inlining the result on
TableInfo.bind_result; the C++ extension then skips the per-scan
bind RPC. Only valid when function is a
@bind_fixed_schema-decorated TableFunctionGenerator subclass
â the decoratorâs contract (output is exactly cls.FIXED_SCHEMA,
no per-call inputs) matches whatâs safe to freeze for the catalog
cache lifetime. Setting this on a descriptor whose function is not
decorated raises at descriptor build.
attribute resolved_columns
Section titled âattribute resolved_columnsâThe resolved column schema (explicit or derived from function).
Methods
method to_table_info
Section titled âmethod to_table_infoâto_table_info(schema_name: str) -> TableInfoConvert to TableInfo for catalog response.
method resolve_column_statistics
Section titled âmethod resolve_column_statisticsâresolve_column_statistics() -> TableColumnStatisticsResult | NoneResolve the statistics dict into a :class:TableColumnStatisticsResult.
Returns None if no statistics are defined. Otherwise, converts
each entry to a :class:ColumnStatistics with properly typed PyArrow
scalars inferred from the tableâs column schema.
class TableInfo
Section titled âclass TableInfoâBases: CatalogSchemaObject, ArrowSerializableDataclass
Description
Information about a table in a schema.
Attributes
attribute columns
Section titled âattribute columnsâSerializedSchema
The columns of the table as a PyArrow schema that is serialized as bytes.
attribute not_null_constraints
Section titled âattribute not_null_constraintsâAnnotated[list[int], ArrowType(pa.list_(pa.int32()))]
Column indices with a NOT NULL constraint. Uses ArrowType to specify int32 instead of the default int64.
attribute unique_constraints
Section titled âattribute unique_constraintsâAnnotated[list[list[int]], ArrowType(pa.list_(pa.list_(pa.int32())))]
Column-index groups with a UNIQUE constraint.
attribute check_constraints
Section titled âattribute check_constraintsâlist[str]
SQL CHECK constraint expressions.
attribute primary_key_constraints
Section titled âattribute primary_key_constraintsâAnnotated[list[list[int]], ArrowType(pa.list_(pa.list_(pa.int32())))]
Column-index groups forming the primary key.
attribute foreign_key_constraints
Section titled âattribute foreign_key_constraintsâAnnotated[list[bytes], ArrowType(pa.list_(pa.binary()))]
Serialized foreign-key constraint specs.
attribute supports_insert
Section titled âattribute supports_insertâbool
Write-support flag â whether the table supports INSERT.
attribute supports_update
Section titled âattribute supports_updateâbool
Write-support flag â whether the table supports UPDATE.
attribute supports_delete
Section titled âattribute supports_deleteâbool
Write-support flag â whether the table supports DELETE.
attribute supports_returning
Section titled âattribute supports_returningâbool
When False (the default), the C++ extension rejects INSERT/UPDATE/DELETE ⌠RETURNING at plan time with a BinderException. Workers that can emit the affected rows from their write functions must opt in by setting this to True.
attribute supports_column_statistics
Section titled âattribute supports_column_statisticsâbool
Statistics capability flag â indicates this table can provide column statistics.
attribute scan_function
Section titled âattribute scan_functionâAnnotated[bytes | None, ArrowType(pa.binary())]
Optional inlined function-discovery result. When
populated, the C++ extension uses the cached value and skips the
corresponding catalog_table_scan_function_get RPC. Bytes are the
IPC payload from ScanFunctionResult.serialize(). Populating this
freezes the function args for the lifetime of the catalog cache
(until catalog_version bumps); workers whose function args change
more frequently than catalog_version (rotating credentials,
presigned URLs, per-transaction snapshots) MUST leave it null so the
per-bind RPC continues to fire.
attribute insert_function
Section titled âattribute insert_functionâAnnotated[bytes | None, ArrowType(pa.binary())]
Optional inlined INSERT function-discovery result. Same
caching contract as scan_function.
attribute update_function
Section titled âattribute update_functionâAnnotated[bytes | None, ArrowType(pa.binary())]
Optional inlined UPDATE function-discovery result. Same
caching contract as scan_function.
attribute delete_function
Section titled âattribute delete_functionâAnnotated[bytes | None, ArrowType(pa.binary())]
Optional inlined DELETE function-discovery result. Same
caching contract as scan_function.
attribute cardinality_estimate
Section titled âattribute cardinality_estimateâAnnotated[int | None, ArrowType(pa.int64())]
Optional inlined cardinality estimate. When
populated, the C++ extension uses it directly and skips the
table_function_cardinality RPC â saving one round-trip per bind.
Use for read-only or slow-changing tables where cardinality is
statically known. Freezes the cardinality for the catalog cache
lifetime (until catalog_version bumps); workers whose cardinality
changes faster (e.g. live counters) MUST leave it null.
attribute cardinality_max
Section titled âattribute cardinality_maxâAnnotated[int | None, ArrowType(pa.int64())]
Optional inlined maximum cardinality. Same caching
contract as cardinality_estimate.
attribute column_statistics
Section titled âattribute column_statisticsâAnnotated[bytes | None, ArrowType(pa.binary())]
Optional inlined column statistics. When populated,
the C++ extension uses the cached value and skips the per-bind /
per-table catalog_table_column_statistics_get RPC and the
per-scan table_function_statistics RPC. Bytes are the IPC payload
from serialize_column_statistics(stats, cache_max_age_seconds).
Freezes the resolved stats for the catalog cache lifetime (until
catalog_version bumps); workers whose statistics change faster
than catalog_version (e.g. live counters, rapidly-mutating
dimensions) MUST leave this null so the on-demand RPC continues to
fire.
attribute bind_result
Section titled âattribute bind_resultâAnnotated[bytes | None, ArrowType(pa.binary())]
Optional inlined bind result. Bytes are the IPC payload of
BindResponse.serialize_to_bytes(). When populated, the C++
extension uses these bytes verbatim and skips the per-scan bind
RPC, threading the deserialized BindResult straight into bind_data.
The catalog framework only populates this for tables marked
Table(inline_bind=True) whose function class is
@bind_fixed_schema-decorated â the decoratorâs contract (output
is exactly cls.FIXED_SCHEMA, no per-call inputs, no opaque_data)
matches whatâs safe to freeze for the catalog cache lifetime.
Functions with custom on_bind are not eligible via the framework
path; workers can still inline manually inside their own
schema_contents override when the bind output is independently
known to be stable.
attribute required_filters
Section titled âattribute required_filtersâAnnotated[list[list[str]], ArrowType(pa.list_(pa.list_(pa.string())))]
Required WHERE-filter groups the VGI extensionâs
optimizer pass verifies against any scan (conjunctive normal form):
the outer list is an AND of groups, each inner group is an OR of
dotted-path column references (top-level names like "country" or
struct subfields like "bbox.xmin"). A group is satisfied when any
one of its paths has a filter; every group must be satisfied. So
[["accession_number"], ["ticker", "cik"]] means âaccession_number
AND one of (ticker, cik)â. Empty (default) means no enforcement â the
zero-cost fast path. Satisfaction is prefix-based: a present filter on
a shorter dotted path satisfies any required path itâs a prefix of (a
whole-struct filter on bbox satisfies every "bbox.*" path).
The C++ extension throws BinderException listing any unsatisfied
groups.
Inherited members (4)
commentattribute ¡ from CatalogObjecttagsattribute ¡ from CatalogObjectnameattribute ¡ from CatalogSchemaObjectschema_nameattribute ¡ from CatalogSchemaObject
class View
Section titled âclass ViewâDescription
Declarative view definition.
Immutable.
Attributes
attribute column_comments
Section titled âattribute column_commentsâdict[str, str]
Optional mapping of view output column name to comment. The extension aligns these by name against the columns DuckDB binds from the viewâs query, so only the names that actually appear in the result need entries; unmatched names are ignored.
Methods
method to_view_info
Section titled âmethod to_view_infoâto_view_info(schema_name: str) -> ViewInfoConvert to ViewInfo for catalog response.
class ViewInfo
Section titled âclass ViewInfoâBases: CatalogSchemaObject, ArrowSerializableDataclass
Description
Information about a view in a schema.
Attributes
attribute definition
Section titled âattribute definitionâstr
The definition of the view which is a SQL query string.
attribute column_comments
Section titled âattribute column_commentsâdict[str, str]
Per-column comments, keyed by the viewâs output column
name. Unlike tables (whose column comments ride along as Arrow field
metadata on the serialized columns schema), a view ships only its
SQL definition â DuckDB binds that query to derive the columns â
so view column comments need their own channel. The C++ extension
aligns these by name against the bound output columns and feeds them
into CreateViewInfo.column_comments_map; names that donât match a
bound column are ignored.
Inherited members (4)
commentattribute ¡ from CatalogObjecttagsattribute ¡ from CatalogObjectnameattribute ¡ from CatalogSchemaObjectschema_nameattribute ¡ from CatalogSchemaObject