MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / purify_create_materialized_view_options

Function purify_create_materialized_view_options

src/sql/src/pure.rs:2794–2925  ·  view source on GitHub ↗

Purifies a CREATE MATERIALIZED VIEW statement. Additionally, it adjusts `resolved_ids` if references to ids appear or disappear during the purification. Note that in contrast with [`purify_statement`], this doesn't need to be async, because this function is not making any network calls.

(
    catalog: impl SessionCatalog,
    mz_now: Option<Timestamp>,
    cmvs: &mut CreateMaterializedViewStatement<Aug>,
    resolved_ids: &mut ResolvedIds,
)

Source from the content-addressed store, hash-verified

2792/// Note that in contrast with [`purify_statement`], this doesn't need to be async, because
2793/// this function is not making any network calls.
2794pub fn purify_create_materialized_view_options(
2795 catalog: impl SessionCatalog,
2796 mz_now: Option<Timestamp>,
2797 cmvs: &mut CreateMaterializedViewStatement<Aug>,
2798 resolved_ids: &mut ResolvedIds,
2799) {
2800 // 0. Preparations:
2801 // Prepare an expression that calls `mz_now()`, which we can insert in various later steps.
2802 let (mz_now_id, mz_now_expr) = {
2803 let item = catalog
2804 .resolve_function(&PartialItemName {
2805 database: None,
2806 schema: Some(MZ_NOW_SCHEMA.to_string()),
2807 item: MZ_NOW_NAME.to_string(),
2808 })
2809 .expect("we should be able to resolve mz_now");
2810 (
2811 item.id(),
2812 Expr::Function(Function {
2813 name: ResolvedItemName::Item {
2814 id: item.id(),
2815 qualifiers: item.name().qualifiers.clone(),
2816 full_name: catalog.resolve_full_name(item.name()),
2817 print_id: false,
2818 version: RelationVersionSelector::Latest,
2819 },
2820 args: FunctionArgs::Args {
2821 args: Vec::new(),
2822 order_by: Vec::new(),
2823 },
2824 filter: None,
2825 over: None,
2826 distinct: false,
2827 }),
2828 )
2829 };
2830 // Prepare the `mz_timestamp` type.
2831 let (mz_timestamp_id, mz_timestamp_type) = {
2832 let item = catalog.get_system_type("mz_timestamp");
2833 let full_name = catalog.resolve_full_name(item.name());
2834 (
2835 item.id(),
2836 ResolvedDataType::Named {
2837 id: item.id(),
2838 qualifiers: item.name().qualifiers.clone(),
2839 full_name,
2840 modifiers: vec![],
2841 print_id: true,
2842 },
2843 )
2844 };
2845
2846 let mut introduced_mz_timestamp = false;
2847
2848 for option in cmvs.with_options.iter_mut() {
2849 // 1. Purify `REFRESH AT CREATION` to `REFRESH AT mz_now()`.
2850 if matches!(
2851 option.value,

Callers 1

handle_execute_innerMethod · 0.85

Calls 15

FunctionClass · 0.85
expectMethod · 0.80
is_noneMethod · 0.80
anyMethod · 0.80
resolve_functionMethod · 0.45
to_stringMethod · 0.45
idMethod · 0.45
cloneMethod · 0.45
nameMethod · 0.45
resolve_full_nameMethod · 0.45
get_system_typeMethod · 0.45
visit_expr_mutMethod · 0.45

Tested by

no test coverage detected