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

Method doc_create_materialized_view

src/sql-pretty/src/doc.rs:723–796  ·  view source on GitHub ↗
(
        &'a self,
        v: &'a CreateMaterializedViewStatement<T>,
    )

Source from the content-addressed store, hash-verified

721 }
722
723 pub(crate) fn doc_create_materialized_view<'a, T: AstInfo>(
724 &'a self,
725 v: &'a CreateMaterializedViewStatement<T>,
726 ) -> RcDoc<'a> {
727 let mut docs = vec![];
728 docs.push(RcDoc::text(format!(
729 "CREATE{}{} MATERIALIZED VIEW{} {}",
730 if v.if_exists == IfExistsBehavior::Replace {
731 " OR REPLACE"
732 } else {
733 ""
734 },
735 if v.replacement_for.is_some() {
736 " REPLACEMENT"
737 } else {
738 ""
739 },
740 if v.if_exists == IfExistsBehavior::Skip {
741 " IF NOT EXISTS"
742 } else {
743 ""
744 },
745 v.name,
746 )));
747 if !v.columns.is_empty() {
748 docs.push(bracket(
749 "(",
750 comma_separate(|c| self.doc_display_pass(c), &v.columns),
751 ")",
752 ));
753 }
754 if let Some(target) = &v.replacement_for {
755 docs.push(RcDoc::text(format!(
756 "FOR {}",
757 target.to_ast_string_simple()
758 )));
759 }
760 match (&v.in_cluster, &v.in_cluster_replica) {
761 (Some(cluster), Some(replica)) => {
762 docs.push(RcDoc::text(format!(
763 "IN CLUSTER {} REPLICA {}",
764 cluster.to_ast_string_simple(),
765 replica.to_ast_string_simple(),
766 )));
767 }
768 (Some(cluster), None) => {
769 docs.push(RcDoc::text(format!(
770 "IN CLUSTER {}",
771 cluster.to_ast_string_simple(),
772 )));
773 }
774 (None, Some(replica)) => {
775 docs.push(RcDoc::text(format!(
776 "IN REPLICA {}",
777 replica.to_ast_string_simple(),
778 )));
779 }
780 (None, None) => {}

Callers 1

to_docMethod · 0.80

Calls 8

bracketFunction · 0.85
comma_separateFunction · 0.85
nest_titleFunction · 0.85
intersperse_line_nestFunction · 0.85
doc_display_passMethod · 0.80
doc_queryMethod · 0.80
pushMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected