Clean up some redundant code in parser (#741)

This commit is contained in:
Andrew Lamb 2022-12-01 13:12:27 -05:00 committed by GitHub
parent 528b3f2234
commit f621142f89
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4369,13 +4369,7 @@ impl<'a> Parser<'a> {
} else if self.parse_keyword(Keyword::VALUES) { } else if self.parse_keyword(Keyword::VALUES) {
SetExpr::Values(self.parse_values()?) SetExpr::Values(self.parse_values()?)
} else if self.parse_keyword(Keyword::TABLE) { } else if self.parse_keyword(Keyword::TABLE) {
let token1 = self.peek_token(); SetExpr::Table(Box::new(self.parse_as_table()?))
let token2 = self.peek_nth_token(1);
let token3 = self.peek_nth_token(2);
self.next_token();
self.next_token();
self.next_token();
SetExpr::Table(Box::new(self.parse_as_table(token1, token2, token3)?))
} else { } else {
return self.expected( return self.expected(
"SELECT, VALUES, or a subquery in the query body", "SELECT, VALUES, or a subquery in the query body",
@ -4575,12 +4569,11 @@ impl<'a> Parser<'a> {
} }
/// Parse `CREATE TABLE x AS TABLE y` /// Parse `CREATE TABLE x AS TABLE y`
pub fn parse_as_table( pub fn parse_as_table(&mut self) -> Result<Table, ParserError> {
&self, let token1 = self.next_token();
token1: Token, let token2 = self.next_token();
token2: Token, let token3 = self.next_token();
token3: Token,
) -> Result<Table, ParserError> {
let table_name; let table_name;
let schema_name; let schema_name;
if token2 == Token::Period { if token2 == Token::Period {