Skip to main content

Module view_definition

Module view_definition 

Source
Expand description

The normalized shape of a DDL-defined (or seeded) materialized view, and the validation shared by the DDL executor and the registry loader. The normalized shape of a DDL-defined (or seeded) materialized view – the three queries plus every option – and the one validate_view_definition function shared by the DDL executor (rust/public/src/servers/view_ddl.rs) and the registry loader (view_registry.rs), so a definition the loader would skip can never be accepted at CREATE time in the first place.

Structs§

ViewDefinition
The normalized shape of a CREATE MATERIALIZED VIEW definition – every option plus the three queries – independent of whether it arrived over DDL or was seeded by a migration (log_stats_view.rs’s log_stats_view_definition).
ViewOptions
The non-query, non-update_group options a ViewDefinition carries, serialized as JSON in lakehouse_view_set_definitions.view_options. update_group lives in its own column instead (reload() sorts and the registry loader projects on it), and definition_sql is the verbatim DDL text kept for display/audit only – neither belongs here.

Functions§

build_sql_batch_view
Builds the SqlBatchView a ViewDefinition describes. This is most of the validation – planning the extract query catches syntax errors, unknown tables and unknown columns, and yields the schema every later check inspects – so callers (the DDL executor, the registry loader) must call this before validate_view_definition, never after.
check_view_set_name_charset
Fast, redundant, name-only pre-check – also enforced, exhaustively, by validate_view_definition, which remains the sole enforcement point since it is the only check that also runs on rows the registry loader reads back. ^[a-z_][a-z0-9_]{0,254}$, not starting with __ (which would collide with a view’s own __<name>__partitions internal registration), and not source (substituted for {source} in every merge query and registered on every merge’s session context).
parse_time_delta
Parses a "<n> <unit>" string (e.g. "1 day", "2 hours") into a TimeDelta. Accepted units, singular or plural: second(s), minute(s), hour(s), day(s).
validate_view_definition
Every check runs before a definition’s row is written, in this one function shared by the DDL executor and the registry loader – so a definition the loader would skip can never be accepted at CREATE time in the first place. view must already be the result of build_sql_batch_view over def – constructing it is most of the validation (it plans the extract query and yields the schema every check below inspects). factory is the factory view was built against – every other definition, for the DDL executor, or only the definitions in a strictly lower update_group processed so far, for the registry loader – which the update-group ordering check below reads.