tkalkirill commented on code in PR #5113:
URL: https://github.com/apache/calcite/pull/5113#discussion_r3621535388


##########
core/src/main/java/org/apache/calcite/sql/SqlDialect.java:
##########
@@ -1081,37 +1081,49 @@ protected static void unparseFetchUsingAnsi(SqlWriter 
writer, @Nullable SqlNode
           writer.startList(SqlWriter.FrameTypeEnum.FETCH);
       writer.keyword("FETCH");
       writer.keyword("NEXT");
-      if (fetch instanceof SqlLiteral
-          || fetch instanceof SqlDynamicParam) {
-        fetch.unparse(writer, -1, -1);
-      } else {
-        final SqlWriter.Frame expressionFrame = writer.startList("(", ")");
-        if (fetch instanceof SqlCall) {
-          writer.getDialect().unparseCall(writer, (SqlCall) fetch, 0, 0);
-        } else {
-          fetch.unparse(writer, 0, 0);
-        }
-        writer.endList(expressionFrame);
-      }
+      unparseOffsetFetchExpression(writer, fetch);
       writer.keyword("ROWS");
       writer.keyword("ONLY");
       writer.endList(fetchFrame);
     }
   }
 
+  private static void unparseOffsetExpression(SqlWriter writer, SqlNode 
offset) {
+    if (offset instanceof SqlCall) {
+      writer.getDialect().unparseCall(writer, (SqlCall) offset, 0, 0);
+    } else {
+      offset.unparse(writer, 0, 0);
+    }
+  }
+
+  private static void unparseOffsetFetchExpression(SqlWriter writer, SqlNode 
node) {

Review Comment:
   I didn't manage to merge everything completely, but I did refactor it a bit.



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