mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-09-09 15:40:32 +00:00
Support for IF NOT EXISTS
in ALTER TABLE ADD COLUMN (#707)
This commit is contained in:
parent
bae682255d
commit
886875f3bf
3 changed files with 110 additions and 11 deletions
|
@ -3205,9 +3205,22 @@ impl<'a> Parser<'a> {
|
|||
new_partitions: partitions,
|
||||
}
|
||||
} else {
|
||||
let _ = self.parse_keyword(Keyword::COLUMN);
|
||||
let column_keyword = self.parse_keyword(Keyword::COLUMN);
|
||||
|
||||
let if_not_exists = if dialect_of!(self is PostgreSqlDialect | BigQueryDialect | GenericDialect)
|
||||
{
|
||||
self.parse_keywords(&[Keyword::IF, Keyword::NOT, Keyword::EXISTS])
|
||||
|| if_not_exists
|
||||
} else {
|
||||
false
|
||||
};
|
||||
|
||||
let column_def = self.parse_column_def()?;
|
||||
AlterTableOperation::AddColumn { column_def }
|
||||
AlterTableOperation::AddColumn {
|
||||
column_keyword,
|
||||
if_not_exists,
|
||||
column_def,
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if self.parse_keyword(Keyword::RENAME) {
|
||||
|
@ -5858,7 +5871,6 @@ mod tests {
|
|||
|
||||
#[cfg(test)]
|
||||
mod test_parse_data_type {
|
||||
|
||||
use crate::ast::{
|
||||
CharLengthUnits, CharacterLength, DataType, ExactNumberInfo, ObjectName, TimezoneInfo,
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue