Skip to main content

build_factory

Function build_factory 

Source
pub async fn build_factory(
    base: &Arc<ViewFactory>,
    rows: &[ViewDefinitionRow],
    runtime: Arc<RuntimeEnv>,
    lake: Arc<DataLakeConnection>,
    session_configurator: Arc<dyn SessionConfigurator>,
    purpose: BuildPurpose,
) -> Result<(Arc<ViewFactory>, Vec<BuildFailure>), Error>
Expand description

Builds a factory from an explicit row set instead of store.list(), so a caller already holding rows inside an open transaction (the DDL executor’s dependent-protection check) can validate against them without a second, pool-backed read that would not see its own uncommitted write. reload() calls this too, after its own store.list(). async because building each row’s SqlBatchView is itself async and needs runtime/lake/ session_configurator to plan the extract query.

Builds incrementally as a fixpoint: let mut factory = (**base).clone(); then, per row in the order given ((update_group NULLS LAST, view_set_name)), build and validate its SqlBatchView against Arc::new(factory.clone()) – the built-ins plus every already-folded-in row – and only then factory.add_global_view(...). Daemon rows are sorted sources-first by their group, but an on-demand row has no group, so one may sort before an on-demand view it reads; the rows that failed are therefore retried for as long as the previous pass added at least one view. A row that fails to parse, or still fails to build or validate when a pass adds nothing, is skipped, not fatal: collected into the returned failed-set with its reason, so one broken definition cannot take out every other view set. Whether that skip is also logged and metered is purpose’s call.