mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-10-12 23:12:01 +00:00
Add support for ATTACH DATABASE (#989)
This commit is contained in:
parent
7723ea56c5
commit
495d0a02d5
4 changed files with 50 additions and 0 deletions
|
@ -456,6 +456,7 @@ impl<'a> Parser<'a> {
|
|||
Ok(Statement::Query(Box::new(self.parse_query()?)))
|
||||
}
|
||||
Keyword::TRUNCATE => Ok(self.parse_truncate()?),
|
||||
Keyword::ATTACH => Ok(self.parse_attach_database()?),
|
||||
Keyword::MSCK => Ok(self.parse_msck()?),
|
||||
Keyword::CREATE => Ok(self.parse_create()?),
|
||||
Keyword::CACHE => Ok(self.parse_cache_table()?),
|
||||
|
@ -543,6 +544,18 @@ impl<'a> Parser<'a> {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn parse_attach_database(&mut self) -> Result<Statement, ParserError> {
|
||||
let database = self.parse_keyword(Keyword::DATABASE);
|
||||
let database_file_name = self.parse_expr()?;
|
||||
self.expect_keyword(Keyword::AS)?;
|
||||
let schema_name = self.parse_identifier()?;
|
||||
Ok(Statement::AttachDatabase {
|
||||
database,
|
||||
schema_name,
|
||||
database_file_name,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn parse_analyze(&mut self) -> Result<Statement, ParserError> {
|
||||
self.expect_keyword(Keyword::TABLE)?;
|
||||
let table_name = self.parse_object_name()?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue