Skip to content

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 by SystemNamespaceDef, SystemTableDef, SystemViewDef.
  • SystemObjectScanner (core/catalog, ai.floedb.floecat.systemcatalog.spi.scanner) – Exposes schema() and a lazy scan(SystemObjectScanContext) that returns Stream<SystemObjectRow>. Scanners must be allocation-light, respect the Arrow schema, and keep rows as Object[].
  • 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’s scannerId. EngineCatalogProvider is 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 complete CatalogContext, 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 to SystemDefinitionRegistry. It exposes the shared internal provider, engine providers, and environment providers; composition happens later in SystemNodeRegistry.
  • SystemNodeRegistry + SystemGraph – The registry filters the snapshot for the requested environment/engine context, materialises GraphNodes and SystemTableNodes, and caches the result. It composes the selected providers into one logical catalog. Identical definitions are deduplicated; conflicting definitions fail during materialization. SystemGraph builds GraphSnapshots from those nodes and keeps them in an LRU LinkedHashMap keyed by the complete catalog context. Each snapshot stores namespace buckets, table relations, and a nodesById map 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 by FloecatInternalProvider/SystemNodeRegistry (not from information_schema scans). Constraints are explicit metadata (SystemTable.constraints) and are validated during builtin catalog load. The runtime currently de-duplicates only CT_NOT_NULL between 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_table when provided.
  • Column reference note: use column_id only when the corresponding SystemColumn.id is defined. If a column has no id, use column_name (and constraint-local ordinal) and omit column_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 t resolves to namespace t rather 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 because findNamespaceId can’t map it to an existing namespace.
  • CatalogGraphView / MetaGraph – The composite graph view implements SystemObjectGraphView and exposes an immutable view over MetadataGraph plus the _system snapshot from SystemGraph. SystemObjectScanContext receives this view and uses it for every lookup, so scanners consistently benefit from the metadata graph’s caches.
  • Registry-level engine hints – SystemObjectsRegistry carries a repeated ScopedMetadataRule scoped_metadata section 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 by ScopedMetadataRule and travel alongside the node-level definitions, so the planner and scanners can deserialize them without adding new system tables (see SystemObjectsRegistry.scoped_metadata in core/proto/src/main/proto/floecat/query/system_objects_registry.proto).
  • Each payload_type identifies 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 new payload_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:

  1. The information_schema namespace (SystemNamespaceDef).
  2. 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, and information_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:

  1. ctx.listNamespaces()/ctx.listTables() reuse the graph view, so the catalog’s graph snapshot is only enumerated once per scan.
  2. columns resolves schemas via ctx.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

  1. Implement EngineCatalogProvider for engine-owned capabilities and live engine metadata. Engine-owned tables use TABLE_BACKEND_KIND_ENGINE and leave scannerId empty. Leave loadSystemCatalog() empty when engine metadata is live rather than PBtxt-backed.
  2. Implement CatalogEnvironmentProvider for environment-owned relations. Return definitions and scanners from the complete CatalogContext; do not duplicate engine capabilities in the environment provider. Environment tables use TABLE_BACKEND_KIND_FLOECAT or TABLE_BACKEND_KIND_STORAGE.
  3. Emit rows with SystemObjectRow – SystemObjectRow is a cheap wrapper around Object[]. Use SystemObjectScanContext for every graph lookup (catalog, namespace, table, schema) so you benefit from CatalogGraphView’s caches.
  4. Register the relevant provider with ServiceLoader. Engine providers use META-INF/services/ai.floedb.floecat.systemcatalog.spi.EngineCatalogProvider; environment providers use META-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

  • SystemGraph caches snapshots in an access-ordered LinkedHashMap sized by floecat.system.graph.snapshot-cache-size (default 16). Each snapshot already buckets namespaces, relations, and node lookups, so repeated _system scans never rebuild the graph.
  • SystemObjectScanContext keeps the catalog/namespace ResourceIds, reuses CatalogGraphView enumeration methods, and caches listNamespaces, listTables, and columnTypes. Scanners should not duplicate this caching logic – the context forwards to the cached graph view that already talks to MetadataGraph. SystemNodeRegistry.resourceId generates deterministic UUIDs for engine/kind/signature tuples, so avoid parsing ResourceId.id strings and build every system ResourceId via the helper.
  • CatalogGraphView/MetaGraph implement SystemObjectGraphView (ai.floedb.floecat.systemcatalog.spi.scanner) so that the core catalog module stays unaware of the full metadata graph. SystemGraph answers _system requests while MetadataGraph handles 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 correct SystemObjectScanner by calling provide(scannerId, context) on the selected provider list.
  • Keep scanners lazy and stateless. Every SystemObjectScanner should stream rows, avoid boxing, and match its SchemaColumn[] exactly. The shared SystemObjectScanContext is the only place scanners should touch metadata – everything else (name resolution, schema parsing, column typing) is already cached.