-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: lmpl `DropView` * chore: codefmt
- Loading branch information
Showing
14 changed files
with
168 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use crate::binder::{lower_case_name, Binder}; | ||
use crate::errors::DatabaseError; | ||
use crate::planner::operator::drop_view::DropViewOperator; | ||
use crate::planner::operator::Operator; | ||
use crate::planner::LogicalPlan; | ||
use crate::storage::Transaction; | ||
use sqlparser::ast::ObjectName; | ||
use std::sync::Arc; | ||
|
||
impl<T: Transaction> Binder<'_, '_, T> { | ||
pub(crate) fn bind_drop_view( | ||
&mut self, | ||
name: &ObjectName, | ||
if_exists: &bool, | ||
) -> Result<LogicalPlan, DatabaseError> { | ||
let view_name = Arc::new(lower_case_name(name)?); | ||
|
||
Ok(LogicalPlan::new( | ||
Operator::DropView(DropViewOperator { | ||
view_name, | ||
if_exists: *if_exists, | ||
}), | ||
vec![], | ||
)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
use crate::execution::{Executor, WriteExecutor}; | ||
use crate::planner::operator::drop_view::DropViewOperator; | ||
use crate::storage::{StatisticsMetaCache, TableCache, Transaction, ViewCache}; | ||
use crate::throw; | ||
use crate::types::tuple_builder::TupleBuilder; | ||
|
||
pub struct DropView { | ||
op: DropViewOperator, | ||
} | ||
|
||
impl From<DropViewOperator> for DropView { | ||
fn from(op: DropViewOperator) -> Self { | ||
DropView { op } | ||
} | ||
} | ||
|
||
impl<'a, T: Transaction + 'a> WriteExecutor<'a, T> for DropView { | ||
fn execute_mut( | ||
self, | ||
(table_cache, view_cache, _): (&'a TableCache, &'a ViewCache, &'a StatisticsMetaCache), | ||
transaction: &'a mut T, | ||
) -> Executor<'a> { | ||
Box::new( | ||
#[coroutine] | ||
move || { | ||
let DropViewOperator { | ||
view_name, | ||
if_exists, | ||
} = self.op; | ||
|
||
throw!(transaction.drop_view( | ||
view_cache, | ||
table_cache, | ||
view_name.clone(), | ||
if_exists | ||
)); | ||
|
||
yield Ok(TupleBuilder::build_result(format!("{}", view_name))); | ||
}, | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use crate::catalog::TableName; | ||
use fnck_sql_serde_macros::ReferenceSerialization; | ||
use std::fmt; | ||
use std::fmt::Formatter; | ||
|
||
#[derive(Debug, PartialEq, Eq, Clone, Hash, ReferenceSerialization)] | ||
pub struct DropViewOperator { | ||
/// Table name to insert to | ||
pub view_name: TableName, | ||
pub if_exists: bool, | ||
} | ||
|
||
impl fmt::Display for DropViewOperator { | ||
fn fmt(&self, f: &mut Formatter) -> fmt::Result { | ||
write!( | ||
f, | ||
"Drop View {}, If Exists: {}", | ||
self.view_name, self.if_exists | ||
)?; | ||
|
||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
# F031-16: DROP VIEW statement: RESTRICT clause | ||
|
||
# TODO: Support `DROP VIEW` | ||
|
||
statement ok | ||
CREATE TABLE TABLE_F031_16_01_01 ( ID INT PRIMARY KEY, A INTEGER ); | ||
|
||
statement ok | ||
CREATE VIEW VIEW_F031_16_01_01 AS SELECT A FROM TABLE_F031_16_01_01; | ||
|
||
# DROP VIEW VIEW_F031_16_01_01 | ||
statement ok | ||
DROP VIEW VIEW_F031_16_01_01 |