beyond1920 commented on a change in pull request #2524:
URL: https://github.com/apache/calcite/pull/2524#discussion_r716129706



##########
File path: 
core/src/main/java/org/apache/calcite/sql/SqlSessionTableFunction.java
##########
@@ -79,5 +91,37 @@ public SqlSessionTableFunction() {
       return opName + "(TABLE table_name, DESCRIPTOR(timecol), "
           + "DESCRIPTOR(key) optional, datetime interval)";
     }
+
+    /**
+     * If partition-by clause and partition key descriptor both appear for a 
session window,
+     * validate they must be equals with each other.
+     *
+     * @param callBinding            The call binding
+     * @param partitionKeysInDescriptor partition keys which are defined in 
descriptor operand.
+     */
+    private void validateNoPartitionKeysConflict(SqlCallBinding callBinding,
+        List<SqlNode> partitionKeysInDescriptor) {
+      if (partitionKeysInDescriptor.isEmpty()) {
+        return;
+      }
+      SqlPartitionBy sqlPartitionBy = (SqlPartitionBy) callBinding.operand(0);
+      if (sqlPartitionBy.partitionList.isEmpty()) {
+        return;
+      }
+      List<String> partitionKeyNamesInClause = parsePartitionKeyNames(
+          sqlPartitionBy.partitionList);
+      List<String> partitionKeyNamesInDescriptor = parsePartitionKeyNames(
+          partitionKeysInDescriptor);
+      if (!partitionKeyNamesInClause.equals(partitionKeyNamesInDescriptor)) {
+        throw 
SqlUtil.newContextException(sqlPartitionBy.partitionList.getParserPosition(),
+            
RESOURCE.differentPartitionKeysForSessionWTF(partitionKeyNamesInClause.toString(),
+                partitionKeyNamesInDescriptor.toString()));
+      }

Review comment:
       Hi, Danny, drop the old `DESCRIPTOR(partition_key) ` syntax is an option.
   however it would cause compatibility problem, I'm not sure whether the user 
could accept this uncompatible update.




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