System Objects¶
System objects are the catalog-level row sources that live inside the _system account: information_schema.*, pg_catalog.*, and provider-contributed tables or views. Unlike user tables, these objects are not backed by persisted blobs – they are synthesised from builtin catalog metadata, cached graph snapshots, and scanners. A request selects an environment and an engine independently. The builtin catalog load/caching pipeline is described in Builtin catalog architecture; EngineCatalogProvider supplies engine capabilities and engine-owned relations, while CatalogEnvironmentProvider supplies environment-owned relations.
Client contract for GetSqlObjectsRegistry¶
SystemObjectsService.GetSystemObjects is retained as a deprecated compatibility alias for older
clients; it has the same result and authorization as GetSqlObjectsRegistry.
GetSqlObjectsRegistry never returns namespace/table/view metadata – it only streams the function/operator/type/cast/collation/aggregate definitions plus any registry hints. The _system graph view exposes the actual relations (namespaces, tables, views, SystemTableNodes, etc.) for scanning and planner resolution, so duplicate metadata would confuse downstream consumers and could expose synthetic tables twice. Use the _system graph view (SystemGraph/CatalogGraphView) whenever you need the actual relation graph; rely on GetSqlObjectsRegistry solely for the recursive builtin registry data.
System resource identifiers¶
Every system node exposes a ResourceId whose id field looks like a UUID but is deterministically computed. The canonical identity string for the object (namespace-qualified name plus any versioned signatures) is hashed with SHA-256, truncated to 16 bytes, forced to carry the fixed two-byte marker 0xABCD, and then XORed with a catalog-specific mask. The marker distinguishes system-generated IDs from arbitrary UUIDs, while the selected catalog kind remains part of the identity. The generated bytes also obey the RFC-4122 variant 4 layout (version nibble 4, variant bits 10), so serializers and tooling can treat them like canonical UUIDs while the mask still exposes a deterministic catalog identity. When an engine is selected, its kind names the system catalog; otherwise the selected environment names it; when neither axis is selected, the catalog is floecat_internal. Use CatalogContext.effectiveSystemCatalogKind() and SystemNodeRegistry.systemCatalogContainerId(...) whenever you need that identifier during builtin graph construction or tests.
System catalog translation helpers¶
Metagraph and system-graph callers never rewrite _system IDs themselves. Instead they use a dedicated SystemCatalogTranslator that knows how to:
* normalize any UUID carrying the system marker so its account_id is _system before the graph cache looks it up,
* map user-provided NameRefs into the selected catalog context before a namespace or table lookup,
* alias the matched system name back to the user catalog so responses still show examples.information_schema.pg_class.
These translator helpers keep ID/name wrangling centralized, which makes it obvious why the graph view can resolve _system objects even when the CLI is using a different account or catalog. Callers simply run user inputs through SystemCatalogTranslator before hitting SystemGraph/MetaGraph, and every system snapshot is still keyed by the _system account in the registry.
Naming requirements for builtin relations¶
Every builtin object (namespaces, tables, views, functions, operators, etc.) must be namespace-qualified. Definitions without a namespace (no dot in the canonical name) are rejected by catalog validation in normal provider flows, and the graph build still keeps a defensive skip fallback for malformed data that bypasses validation (for example, ad-hoc test catalogs). This keeps namespace buckets deterministic and avoids accidentally seeding the graph with tables that should live in the root namespace. When designing engine-specific catalog fragments, always include the namespace path (e.g., pg_catalog.pg_class, not just pg_class).
SystemNodeRegistry uses that canonical qualified name for identity (ResourceId) and namespace resolution, but display labels are intentionally independent. By default the registry materializes the leaf name (name.name) for function/operator/type/collation/aggregate node displayNames, while namespace/table/view display labels still come from the catalog definition. Providers may still override display labels explicitly when they need qualified names for their own UX.
Namespace-scoping validation defaults are defined in SystemCatalogValidator.NamespaceScopePolicy.defaultPolicy() and are intentionally explicit for OSS plugin authors:
- scoped by default (must be namespace-qualified and reference a known namespace): function, type, table, view
- not scoped by default (no namespace requirement unless a stricter policy is selected): operator, cast, collation, aggregate
Both ServiceLoaderSystemCatalogProvider and FloecatInternalProvider fail fast on Severity.ERROR validation issues during catalog load, so extension authors should treat these defaults as part of the public contract.
Architecture overview¶
┌────────────────────────────────────────────┐
│ ServiceLoaderSystemCatalogProvider │
│ - discovers engine providers │
│ - discovers environment providers │
└────────────────────────────────────────────┘
↓
┌────────────────────────────────────────────┐
│ SystemCatalogData + SystemEngineCatalog │
└────────────────────────────────────────────┘
↓
┌────────────────────────────────────────────┐
│ SystemNodeRegistry → BuiltinNodes │
│ - filters ScopedMetadataRule rules │
└────────────────────────────────────────────┘
↓
┌────────────────────────────────────────────┐
│ SystemGraph (GraphSnapshot cache) │
│ - reuses BuiltinNodes to build namespace │
│ buckets & SystemTableNode instances │
└────────────────────────────────────────────┘
↓
┌────────────────────────────────────────────┐
│ MetaGraph / CatalogGraphView │
│ (implements SystemObjectGraphView) │
│ - resolves `_system` nodes via SystemGraph │
│ - delegates to MetadataGraph for user data │
└────────────────────────────────────────────┘
↓
┌────────────────────────────────────────────┐
│ SystemObjectScanContext (ctx) │
│ - built with CatalogGraphView/SystemGraph │
└────────────────────────────────────────────┘
↓
┌────────────────────────────────────────────┐
│ SystemObjectScanner → SystemObjectRow │
└────────────────────────────────────────────┘
The core pieces:
SystemObjectDef– Describes a system row source (NameRef,SchemaColumn[],scannerId,TableBackendKind, etc.). Implemented bySystemNamespaceDef,SystemTableDef,SystemViewDef.SystemObjectScanner(core/catalog,ai.floedb.floecat.systemcatalog.spi.scanner) – Exposesschema()and a lazyscan(SystemObjectScanContext)that returnsStream<SystemObjectRow>. Scanners must be allocation-light, respect the Arrow schema, and keep rows asObject[].SystemObjectScannerProvider– SPI for internal or environment-owned definitions and scanners.definitions()lists the definitions for the supplied context.supports(NameRef, context)gates when a definition applies.provide(scannerId, context)lets the runtime look up a scanner for a FLOECAT node’sscannerId.EngineCatalogProvideris metadata-only: engine-owned tables are executed by the engine and do not use this scanner SPI.CatalogEnvironmentProvider– SPI for environment-owned relations and scanners. Its methods receive the completeCatalogContext, so an environment can be selected independently of the engine whose capabilities describe the request.ServiceLoaderSystemCatalogProvider– Discovers engine and environment providers separately, loads optional static engine catalog data, and hands it toSystemDefinitionRegistry. It exposes the shared internal provider, engine providers, and environment providers; composition happens later inSystemNodeRegistry.SystemNodeRegistry+SystemGraph– The registry filters the snapshot for the requested environment/engine context, materialisesGraphNodes andSystemTableNodes, and caches the result. It composes the selected providers into one logical catalog. Identical definitions are deduplicated; conflicting definitions fail during materialization.SystemGraphbuildsGraphSnapshots from those nodes and keeps them in an LRULinkedHashMapkeyed by the complete catalog context. Each snapshot stores namespace buckets, table relations, and anodesByIdmap for constant-time resolution.- System constraint catalog – Planner/system constraint lookups are backed by an immutable cache keyed by
(engineKind, engineVersion, systemRelationId)and built from the pbtxt-backed builtin table definitions loaded byFloecatInternalProvider/SystemNodeRegistry(not frominformation_schemascans). Constraints are explicit metadata (SystemTable.constraints) and are validated during builtin catalog load. The runtime currently de-duplicates onlyCT_NOT_NULLbetween explicit and nullable-derived implicit entries (and keeps other constraint kinds as declared), so semantic de-duplication of PK/UNIQUE/FK/CHECK is intentionally out of scope here. - Validator note: FK referenced-column target validation resolves through
referenced_tablewhen provided. - Column reference note: use
column_idonly when the correspondingSystemColumn.idis defined. If a column has noid, usecolumn_name(and constraint-localordinal) and omitcolumn_id. - pbtxt authoring example (common constraint types):
system_tables { name { path: "information_schema" name: "orders" } display_name: "orders" backend_kind: TABLE_BACKEND_KIND_FLOECAT floecat { scanner_id: "orders_scanner" } columns { name: "id" type { name: "BIGINT" } nullable: false ordinal: 1 id: 1 } columns { name: "customer_id" type { name: "BIGINT" } nullable: false ordinal: 2 id: 2 } columns { name: "order_no" type { name: "VARCHAR" } nullable: false ordinal: 3 id: 3 } columns { name: "total_amount" type { name: "DECIMAL" } nullable: false ordinal: 4 id: 4 } constraints { name: "pk_orders" type: CT_PRIMARY_KEY columns { column_id: 1 column_name: "id" ordinal: 1 } } constraints { name: "uq_orders_order_no" type: CT_UNIQUE columns { column_id: 3 column_name: "order_no" ordinal: 1 } } constraints { name: "ck_orders_total_non_negative" type: CT_CHECK check_expression: "total_amount >= 0" columns { column_id: 4 column_name: "total_amount" ordinal: 1 } } constraints { name: "fk_orders_customers" type: CT_FOREIGN_KEY columns { column_id: 2 column_name: "customer_id" ordinal: 1 } referenced_table { path: "information_schema" name: "customers" } referenced_columns { column_id: 1 column_name: "id" ordinal: 1 } } constraints { name: "nn_orders_total_amount" type: CT_NOT_NULL columns { column_id: 4 column_name: "total_amount" ordinal: 1 } } } - Namespace resolution – Objects are mapped to namespaces by canonical name, trimming everything after the final dot. That means
tresolves to namespacetrather than a default schema, so every system function/table/view must be defined with a fully qualified name (e.g.,foo.bar). If you need to expose unqualified identifiers you must provide a dedicated namespace node whose canonical path matches the identifier you intend to publish; otherwise the node will be skipped during merging becausefindNamespaceIdcan’t map it to an existing namespace. CatalogGraphView/MetaGraph– The composite graph view implementsSystemObjectGraphViewand exposes an immutable view overMetadataGraphplus the_systemsnapshot fromSystemGraph.SystemObjectScanContextreceives this view and uses it for every lookup, so scanners consistently benefit from the metadata graph’s caches.- Registry-level engine hints –
SystemObjectsRegistrycarries arepeated ScopedMetadataRule scoped_metadatasection that plugins can use to ship shared dictionaries (pg_opfamily/opclass/amop-like payloads) or other planner-only metadata once per(engine_kind, engine_version). These payloads are filtered byScopedMetadataRuleand travel alongside the node-level definitions, so the planner and scanners can deserialize them without adding new system tables (seeSystemObjectsRegistry.scoped_metadataincore/proto/src/main/proto/floecat/query/system_objects_registry.proto). - Each
payload_typeidentifies one dictionary; the validator enforces uniqueness on the(payload_type, engine_kind, min_version, max_version)tuple so you can still ship the same dictionary payload for disjoint version windows but duplicates with the same engine kind and window will be rejected. Treat schema changes as a newpayload_type(or add a suffix) so the planner knows when you actually mean a new payload.
Built-in information_schema¶
InformationSchemaProvider is the default SystemObjectScannerProvider. It unconditionally registers:
- The
information_schemanamespace (SystemNamespaceDef). - Tables
information_schema.tables,information_schema.columns,information_schema.schemata,information_schema.table_constraints,information_schema.key_column_usage,information_schema.referential_constraints,information_schema.check_constraints,information_schema.constraint_column_usage, andinformation_schema.constraint_table_usage(SystemTableDefs) with scanner identifiers.
FloecatInternalProvider wraps InformationSchemaProvider and is selected explicitly as the floecat_internal catalog. It is not seeded into explicit engine or environment selections. A request boundary may select it when both axes are absent; otherwise information_schema must come from the selected provider composition.
Each table wires to a lightweight scanner (TablesScanner, ColumnsScanner, SchemataScanner, plus constraint scanners). These scanners rely on SystemObjectScanContext for cached lookups:
ctx.listNamespaces()/ctx.listTables()reuse the graph view, so the catalog’s graph snapshot is only enumerated once per scan.columnsresolves schemas viactx.graph().tableSchema(table.id()), which delegates through the graph-view/metadata-graph caches so repeated scans avoid redundant schema materialization work.
Constraint view semantics are ANSI-oriented:
- key_column_usage includes PK/UNIQUE/FK key columns (not NOT NULL).
- constraint_column_usage includes columns referenced by each constraint definition:
PK/UNIQUE/NOT NULL/CHECK use local referenced columns, while FK uses referenced-target columns (not FK local key columns).
- For CHECK, rows are emitted only when ConstraintDefinition.columns is populated.
The scanner does not parse check_expression to infer referenced columns.
- referential_constraints maps FK metadata from ConstraintDefinition:
unique_constraint_* uses FK target table/catalog/schema plus referenced_constraint_name
when available, and match_option/update_rule/delete_rule default to NONE/NO ACTION/NO ACTION
when source metadata omits them.
- If referenced_constraint_name is omitted, the scanner infers it only when there is exactly one
matching PK/UNIQUE on the referenced columns in the current constraint index scope; otherwise
unique_constraint_* remains NULL.
Writing your own provider¶
- Implement
EngineCatalogProviderfor engine-owned capabilities and live engine metadata. Engine-owned tables useTABLE_BACKEND_KIND_ENGINEand leavescannerIdempty. LeaveloadSystemCatalog()empty when engine metadata is live rather than PBtxt-backed. - Implement
CatalogEnvironmentProviderfor environment-owned relations. Return definitions and scanners from the completeCatalogContext; do not duplicate engine capabilities in the environment provider. Environment tables useTABLE_BACKEND_KIND_FLOECATorTABLE_BACKEND_KIND_STORAGE. - Emit rows with
SystemObjectRow–SystemObjectRowis a cheap wrapper aroundObject[]. UseSystemObjectScanContextfor every graph lookup (catalog, namespace, table, schema) so you benefit fromCatalogGraphView’s caches. - Register the relevant provider with ServiceLoader. Engine providers use
META-INF/services/ai.floedb.floecat.systemcatalog.spi.EngineCatalogProvider; environment providers useMETA-INF/services/ai.floedb.floecat.systemcatalog.provider.CatalogEnvironmentProvider.
Provider version contract¶
Providers must keep their definitions and scanners aligned with the version they advertise. The
context-aware methods receive the complete CatalogContext, so inspect both axes when a provider's
metadata depends on the selected environment and engine. The scannerId in each FLOECAT definition
must resolve through provide(scannerId, context) under the same context. The merged overlay is
cached per normalized (environmentKind, environmentVersion, engineKind, engineVersion) tuple; if
metadata changes without a context/version change, call targeted registry invalidation before the
next materialization.
Performance & scalability notes¶
SystemGraphcaches snapshots in an access-orderedLinkedHashMapsized byfloecat.system.graph.snapshot-cache-size(default16). Each snapshot already buckets namespaces, relations, and node lookups, so repeated_systemscans never rebuild the graph.SystemObjectScanContextkeeps the catalog/namespaceResourceIds, reusesCatalogGraphViewenumeration methods, and cacheslistNamespaces,listTables, andcolumnTypes. Scanners should not duplicate this caching logic – the context forwards to the cached graph view that already talks toMetadataGraph.SystemNodeRegistry.resourceIdgenerates deterministic UUIDs for engine/kind/signature tuples, so avoid parsingResourceId.idstrings and build every systemResourceIdvia the helper.CatalogGraphView/MetaGraphimplementSystemObjectGraphView(ai.floedb.floecat.systemcatalog.spi.scanner) so that the core catalog module stays unaware of the full metadata graph.SystemGraphanswers_systemrequests whileMetadataGraphhandles user objects, but both feed into the same composite graph view.SystemTableNode.scannerId()carries the bridge between metadata and row generation. Row-oriented components can look up the correctSystemObjectScannerby callingprovide(scannerId, context)on the selected provider list.- Keep scanners lazy and stateless. Every
SystemObjectScannershould stream rows, avoid boxing, and match itsSchemaColumn[]exactly. The sharedSystemObjectScanContextis the only place scanners should touch metadata – everything else (name resolution, schema parsing, column typing) is already cached.