chunweilei commented on a change in pull request #2366:
URL: https://github.com/apache/calcite/pull/2366#discussion_r592008165
##########
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);
+ writeForSystemTimeAsOf(writer, snapshot);
+ writer.keyword("AS");
+ basicCall.operand(1).unparse(writer, 0, 0);
+ } else {
+ tableRef.unparse(writer, 0, 0);
+ writeForSystemTimeAsOf(writer, snapshot);
+ }
}
}
+
+ private static void writeForSystemTimeAsOf(SqlWriter writer, SqlSnapshot
snapshot) {
+ writer.keyword("FOR SYSTEM_TIME AS OF");
+ snapshot.period.unparse(writer, 0, 0);
Review comment:
Maybae it is better to put `writeForSystemTimeAsOf` in
SqlSnapshotOperator.
----------------------------------------------------------------
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:
[email protected]