chunweilei commented on code in PR #2768:
URL: https://github.com/apache/calcite/pull/2768#discussion_r855707344


##########
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:
   Do other systems support 'offset xx limit xx,xx'? It looks a little wired.



##########
core/src/main/codegen/templates/Parser.jj:
##########
@@ -623,8 +630,7 @@ SqlNode OrderedQueryOrExpr(ExprContext exprContext) :
 {
     SqlNode e;
     SqlNodeList orderBy = null;
-    SqlNode start = null;
-    SqlNode count = null;
+    SqlNode[] startCount = {null, null};
 }
 {

Review Comment:
   Is it necessary to use Array to indicate the first value is the offset and 
the second value is the limit? It maybe not a good practice.



-- 
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]

Reply via email to