move our dbsp-based views to materialized views

We will implement normal SQLite-style view-as-an-alias for
compatibility, and will call our incremental views materialized views.
This commit is contained in:
Glauber Costa
2025-08-12 14:06:19 -05:00
parent a6247e891f
commit 770f86e490
6 changed files with 65 additions and 23 deletions

View File

@@ -391,6 +391,29 @@ impl ToTokens for Stmt {
s.append(TK_AS, None)?;
select.to_tokens_with_context(s, context)
}
Self::CreateMaterializedView {
if_not_exists,
view_name,
columns,
select,
} => {
s.append(TK_CREATE, None)?;
s.append(TK_MATERIALIZED, None)?;
s.append(TK_VIEW, None)?;
if *if_not_exists {
s.append(TK_IF, None)?;
s.append(TK_NOT, None)?;
s.append(TK_EXISTS, None)?;
}
view_name.to_tokens_with_context(s, context)?;
if let Some(columns) = columns {
s.append(TK_LP, None)?;
comma(columns, s, context)?;
s.append(TK_RP, None)?;
}
s.append(TK_AS, None)?;
select.to_tokens_with_context(s, context)
}
Self::CreateVirtualTable(create_virtual_table) => {
let CreateVirtualTable {
if_not_exists,

View File

@@ -130,6 +130,17 @@ pub enum Stmt {
/// query
select: Box<Select>,
},
/// `CREATE MATERIALIZED VIEW`
CreateMaterializedView {
/// `IF NOT EXISTS`
if_not_exists: bool,
/// view name
view_name: QualifiedName,
/// columns
columns: Option<Vec<IndexedColumn>>,
/// query
select: Box<Select>,
},
/// `CREATE VIRTUAL TABLE`
CreateVirtualTable(Box<CreateVirtualTable>),
/// `DELETE`