cql3_parser/
alter_materialized_view.rs

1use crate::common::{FQName, WithItem};
2use itertools::Itertools;
3use std::fmt::{Display, Formatter};
4
5/// The data for an `AlterMaterializedView` statement
6#[derive(PartialEq, Debug, Clone)]
7pub struct AlterMaterializedView {
8    /// the name of the materialzied view.
9    pub name: FQName,
10    /// the with options for the view.
11    pub with_clause: Vec<WithItem>,
12}
13
14impl Display for AlterMaterializedView {
15    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
16        write!(
17            f,
18            "ALTER MATERIALIZED VIEW {}{}",
19            self.name,
20            if self.with_clause.is_empty() {
21                "".to_string()
22            } else {
23                format!(
24                    " WITH {}",
25                    self.with_clause.iter().map(|x| x.to_string()).join(" AND ")
26                )
27            }
28        )
29    }
30}