danny0405 commented on a change in pull request #1679: [CALCITE-3620] Remove 
implicit lateral operator for temporal table join
URL: https://github.com/apache/calcite/pull/1679#discussion_r360421067
 
 

 ##########
 File path: 
core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java
 ##########
 @@ -4763,6 +4752,34 @@ private void validateAccess(
     }
   }
 
+  /**
+   * Validates snapshot to a table.
+   *
+   * @param node  The node to validate
+   * @param scope Validator scope to derive type
+   * @param ns    The namespace to lookup table
+   */
+  private void validateSnapshot(
+      SqlNode node,
+      SqlValidatorScope scope,
+      SqlValidatorNamespace ns) {
+    if (node.getKind() == SqlKind.SNAPSHOT) {
+      SqlSnapshot snapshot = (SqlSnapshot) node;
+      SqlNode period = snapshot.getPeriod();
+      RelDataType dataType = deriveType(scope, period);
+      if (dataType.getSqlTypeName() != SqlTypeName.TIMESTAMP) {
+        throw newValidationError(period,
+            
Static.RESOURCE.illegalExpressionForTemporal(dataType.getSqlTypeName().getName()));
+      }
+      if (!ns.getTable().isTemporal()) {
+        List<String> qualifiedName = ns.getTable().getQualifiedName();
+        String tableName = qualifiedName.get(qualifiedName.size() - 1);
+        throw newValidationError(snapshot.getTableRef(),
+            Static.RESOURCE.notTemporalTable(tableName));
+      }
 
 Review comment:
   Tests was already there.

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


With regards,
Apache Git Services

Reply via email to