add SELECT INTO statement variation (#447)

Signed-off-by: Maciej Obuchowski <obuchowski.maciej@gmail.com>
This commit is contained in:
Maciej Obuchowski 2022-03-30 22:01:55 +02:00 committed by GitHub
parent b68e9a3801
commit d38c30e9ff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 74 additions and 2 deletions

View file

@ -380,6 +380,32 @@ fn parse_select_all_distinct() {
);
}
#[test]
fn parse_select_into() {
let sql = "SELECT * INTO table0 FROM table1";
one_statement_parses_to(sql, "SELECT * INTO table0 FROM table1");
let select = verified_only_select(sql);
assert_eq!(
&SelectInto {
temporary: false,
unlogged: 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");
// Do not allow aliases here
let sql = "SELECT * INTO table0 asdf FROM table1";
let result = parse_sql_statements(sql);
assert_eq!(
ParserError::ParserError("Expected end of statement, found: asdf".to_string()),
result.unwrap_err()
)
}
#[test]
fn parse_select_wildcard() {
let sql = "SELECT * FROM foo";
@ -4235,6 +4261,7 @@ fn parse_merge() {
distinct: false,
top: None,
projection: vec![SelectItem::Wildcard],
into: None,
from: vec![TableWithJoins {
relation: TableFactor::Table {
name: ObjectName(vec![Ident::new("s"), Ident::new("foo")]),