Skip to main content

Module ontology

Module ontology 

Source
Expand description

Catalog ontology views derived from existing builtin definitions.

Enumerates builtins that have ontology: Some(...) and generates 4 views:

  • entity_types: from ontology.description + RelationDesc::keys()
  • properties: from mz_columns + mz_comments + semantic type inference
  • semantic_types: small const reference data
  • link_types: from ontology.links on each builtin

Structsยง

Info ๐Ÿ”’

Enumsยง

Lit ๐Ÿ”’
A single typed SQL literal for use inside a VALUES list.

Constantsยง

SEMANTIC_TYPE_DEFS ๐Ÿ”’

Functionsยง

entity_types_view ๐Ÿ”’
esc ๐Ÿ”’
Escape single quotes for SQL string literals. Only safe for trusted compile-time constants (entity names, descriptions, link JSON from Ontology annotations) โ€” never use with user-supplied input.
generate_views ๐Ÿ”’
leak ๐Ÿ”’
Leak a BuiltinView to get a &'static reference. Called exactly 4 times at startup (one per ontology view). These views live for the entire process lifetime (same as LazyLock<&'static BuiltinView> used by other builtins), so the leak is intentional and bounded.
link_types_view ๐Ÿ”’
pk_lit ๐Ÿ”’
Extract all keys from a RelationDesc and return a Lit::Json with shape: {"primary_key": ["id"], "alternate_keys": [["oid"]]}. primary_key is the first declared key; alternate_keys contains any additional unique keys. Returns Lit::Null if no keys are defined.
properties_view ๐Ÿ”’
Build the mz_ontology_properties view: one row per column of every annotated builtin relation.
semantic_types_view ๐Ÿ”’
sql_type_name ๐Ÿ”’
Map a SqlScalarType to the SQL type name used in cast expressions.
values_sql ๐Ÿ”’
Render rows into a SQL VALUES (r1c1,r1c2,...),(r2c1,...) fragment. Used when a VALUES list appears as a subquery inside a larger SQL string rather than as the top-level source of a values_view.
values_view ๐Ÿ”’
Build an ontology view from a static VALUES list. Each row is a Vec<Lit>; all escaping and type-casting is handled here so callers never touch SQL string formatting directly.