snowflake: fix rendering of SELECT TOP (#1070)

This commit is contained in:
Joey Hain 2023-12-22 10:43:31 -08:00 committed by GitHub
parent 1baec96685
commit 2950a843c3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 53 additions and 11 deletions

View file

@ -7843,9 +7843,14 @@ impl<'a> Parser<'a> {
let quantity = if self.consume_token(&Token::LParen) {
let quantity = self.parse_expr()?;
self.expect_token(&Token::RParen)?;
Some(quantity)
Some(TopQuantity::Expr(quantity))
} else {
Some(Expr::Value(self.parse_number_value()?))
let next_token = self.next_token();
let quantity = match next_token.token {
Token::Number(s, _) => s.parse::<u64>().expect("literal int"),
_ => self.expected("literal int", next_token)?,
};
Some(TopQuantity::Constant(quantity))
};
let percent = self.parse_keyword(Keyword::PERCENT);