Skip to content

Commit

Permalink
feat(frontend): allow type conversion to bigint in limit and offset (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
KeXiangWang authored Apr 1, 2024
1 parent 246c940 commit 0f4a54c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
10 changes: 10 additions & 0 deletions e2e_test/batch/order/test_limit.slt.part
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ SELECT a FROM test order by 1 LIMIT 1;
----
11

query I
SELECT a FROM test order by 1 LIMIT 1::bigint;
----
11

query I
SELECT a FROM test order by 1 LIMIT 1::bigint OFFSET 1::bigint;
----
12

# decimal limit
# query I
# SELECT a FROM test order by 1 LIMIT 1.25;
Expand Down
11 changes: 10 additions & 1 deletion src/sqlparser/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5217,13 +5217,22 @@ impl Parser {
if self.parse_keyword(Keyword::ALL) {
Ok(None)
} else {
Ok(Some(self.parse_number_value()?))
let number = self.parse_number_value()?;
// TODO(Kexiang): support LIMIT expr
if self.consume_token(&Token::DoubleColon) {
self.expect_keyword(Keyword::BIGINT)?
}
Ok(Some(number))
}
}

/// Parse an OFFSET clause
pub fn parse_offset(&mut self) -> Result<String, ParserError> {
let value = self.parse_number_value()?;
// TODO(Kexiang): support LIMIT expr
if self.consume_token(&Token::DoubleColon) {
self.expect_keyword(Keyword::BIGINT)?;
}
_ = self.parse_one_of_keywords(&[Keyword::ROW, Keyword::ROWS]);
Ok(value)
}
Expand Down

0 comments on commit 0f4a54c

Please sign in to comment.