mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-22 15:04:04 +00:00
Implement ALTER TABLE DROP COLUMN (#148)
This implements `DROP [ COLUMN ] [ IF EXISTS ] column_name [ CASCADE ]` sub-command of `ALTER TABLE`, which is what PostgreSQL supports https://www.postgresql.org/docs/12/sql-altertable.html (except for the RESTRICT option) Co-authored-by: Nickolay Ponomarev <asqueella@gmail.com>
This commit is contained in:
parent
faeb7d440a
commit
26361fd854
4 changed files with 62 additions and 1 deletions
|
@ -1340,8 +1340,18 @@ impl Parser {
|
|||
new_column_name,
|
||||
}
|
||||
}
|
||||
} else if self.parse_keyword(Keyword::DROP) {
|
||||
let _ = self.parse_keyword(Keyword::COLUMN);
|
||||
let if_exists = self.parse_keywords(&[Keyword::IF, Keyword::EXISTS]);
|
||||
let column_name = self.parse_identifier()?;
|
||||
let cascade = self.parse_keyword(Keyword::CASCADE);
|
||||
AlterTableOperation::DropColumn {
|
||||
column_name,
|
||||
if_exists,
|
||||
cascade,
|
||||
}
|
||||
} else {
|
||||
return self.expected("ADD or RENAME after ALTER TABLE", self.peek_token());
|
||||
return self.expected("ADD, RENAME, or DROP after ALTER TABLE", self.peek_token());
|
||||
};
|
||||
Ok(Statement::AlterTable {
|
||||
name: table_name,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue