You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2021/03/10 10:54:33 UTC

[GitHub] [calcite] vlsi commented on a change in pull request #2366: [CALCITE-4526] Fixup the unparse's output of SqlSnapshot,when tableRel is a SqlAsOperator (jibiyr)

vlsi commented on a change in pull request #2366:
URL: https://github.com/apache/calcite/pull/2366#discussion_r591353652



##########
File path: core/src/main/java/org/apache/calcite/sql/SqlSnapshot.java
##########
@@ -127,10 +129,25 @@ private SqlSnapshotOperator() {
         int leftPrec,
         int rightPrec) {
       final SqlSnapshot snapshot = (SqlSnapshot) call;
-
-      snapshot.tableRef.unparse(writer, 0, 0);
-      writer.keyword("FOR SYSTEM_TIME AS OF");
-      snapshot.period.unparse(writer, 0, 0);
+      SqlNode tableRef = snapshot.tableRef;
+
+      if (tableRef instanceof SqlBasicCall
+          && ((SqlBasicCall) tableRef).getOperator() instanceof SqlAsOperator) {
+        SqlBasicCall basicCall = (SqlBasicCall) tableRef;
+        basicCall.operand(0).unparse(writer, 0, 0);
+        writer.setNeedWhitespace(true);
+        writeKeywordAndPeriod(writer, snapshot);
+        writer.keyword("AS");
+        basicCall.operand(1).unparse(writer, 0, 0);
+      } else {
+        tableRef.unparse(writer, 0, 0);
+        writeKeywordAndPeriod(writer, snapshot);
+      }
     }
   }
+
+  private static void writeKeywordAndPeriod(SqlWriter writer, SqlSnapshot snapshot) {

Review comment:
       ```suggestion
     private static void writeForSustemTimeAsOf(SqlWriter writer, SqlSnapshot snapshot) {
   ```




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org