mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-19 05:30:19 +00:00
feat: Support TABLE
keyword with SELECT INTO
(#487)
This commit is contained in:
parent
6d057ef4df
commit
6b2fc8102f
3 changed files with 11 additions and 3 deletions
|
@ -654,6 +654,7 @@ impl fmt::Display for Values {
|
|||
pub struct SelectInto {
|
||||
pub temporary: bool,
|
||||
pub unlogged: bool,
|
||||
pub table: bool,
|
||||
pub name: ObjectName,
|
||||
}
|
||||
|
||||
|
@ -661,7 +662,8 @@ impl fmt::Display for SelectInto {
|
|||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
let temporary = if self.temporary { " TEMPORARY" } else { "" };
|
||||
let unlogged = if self.unlogged { " UNLOGGED" } else { "" };
|
||||
let table = if self.table { " TABLE" } else { "" };
|
||||
|
||||
write!(f, "INTO{}{} {}", temporary, unlogged, self.name)
|
||||
write!(f, "INTO{}{}{} {}", temporary, unlogged, table, self.name)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3138,10 +3138,12 @@ impl<'a> Parser<'a> {
|
|||
.parse_one_of_keywords(&[Keyword::TEMP, Keyword::TEMPORARY])
|
||||
.is_some();
|
||||
let unlogged = self.parse_keyword(Keyword::UNLOGGED);
|
||||
let table = self.parse_keyword(Keyword::TABLE);
|
||||
let name = self.parse_object_name()?;
|
||||
Some(SelectInto {
|
||||
temporary,
|
||||
unlogged,
|
||||
table,
|
||||
name,
|
||||
})
|
||||
} else {
|
||||
|
|
|
@ -383,13 +383,17 @@ fn parse_select_into() {
|
|||
&SelectInto {
|
||||
temporary: false,
|
||||
unlogged: false,
|
||||
table: false,
|
||||
name: ObjectName(vec![Ident::new("table0")])
|
||||
},
|
||||
only(&select.into)
|
||||
);
|
||||
|
||||
let sql = "SELECT * INTO TEMPORARY UNLOGGED table0 FROM table1";
|
||||
one_statement_parses_to(sql, "SELECT * INTO TEMPORARY UNLOGGED table0 FROM table1");
|
||||
let sql = "SELECT * INTO TEMPORARY UNLOGGED TABLE table0 FROM table1";
|
||||
one_statement_parses_to(
|
||||
sql,
|
||||
"SELECT * INTO TEMPORARY UNLOGGED TABLE table0 FROM table1",
|
||||
);
|
||||
|
||||
// Do not allow aliases here
|
||||
let sql = "SELECT * INTO table0 asdf FROM table1";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue