hannerwang commented on code in PR #2768:
URL: https://github.com/apache/calcite/pull/2768#discussion_r855748201
##########
testkit/src/main/java/org/apache/calcite/sql/parser/SqlParserTest.java:
##########
@@ -3369,6 +3369,48 @@ void checkPeriodPredicate(Checker checker) {
.fails("(?s).*Encountered \"all\" at line 1.*");
}
+ /** Test case for
+ * <a
href="https://issues.apache.org/jira/browse/CALCITE-5086">[CALCITE-5086]
+ * Calcite supports OFFSET start LIMIT count expression</a>. */
+ @Test void testOffsetStartLimitCount() {
+ final String error = "'OFFSET start LIMIT count' is not allowed under the "
+ + "current SQL conformance level";
+ sql("select a from foo order by b, c offset 1 limit 2")
+ .withConformance(SqlConformanceEnum.LENIENT)
+ .ok("SELECT `A`\n"
+ + "FROM `FOO`\n"
+ + "ORDER BY `B`, `C`\n"
+ + "OFFSET 1 ROWS\n"
+ + "FETCH NEXT 2 ROWS ONLY");
+
+ sql("select a from foo order by b, c offset 1 limit ^2^")
+ .withConformance(SqlConformanceEnum.DEFAULT)
+ .fails(error);
+
+ // "limit 2" overrides the earlier "offset 4"
+ final String expected3 = "SELECT `A`\n"
+ + "FROM `FOO`\n"
+ + "OFFSET 2 ROWS\n"
+ + "FETCH NEXT 3 ROWS ONLY";
+ sql("select a from foo offset 4 limit 2,3")
+ .withConformance(SqlConformanceEnum.LENIENT)
Review Comment:
Calcite supports limit xx,xx offset xx now, and the offset will override
previous limit, the syntax looks strange also, however, I think it will be ok
in lenient mode.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]