julianhyde commented on a change in pull request #2444:
URL: https://github.com/apache/calcite/pull/2444#discussion_r656344793



##########
File path: 
core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java
##########
@@ -1500,6 +1503,34 @@ private void handleOffsetFetch(@Nullable SqlNode offset, 
@Nullable SqlNode fetch
     return node;
   }
 
+  private void validatePercentileFunctions(SqlCall call) {
+    // Percentile functions must have a single argument in the order by clause
+    if (call.getOperandList().size() == 2) {
+      SqlBasicCall sqlBasicCall = null;
+      SqlNodeList list = null;
+      SqlNode node1 = call.getOperandList().get(0);
+      SqlNode node2 = call.getOperandList().get(1);
+      if (node1 instanceof SqlBasicCall) {
+        sqlBasicCall = (SqlBasicCall) node1;
+      } else if (node2 instanceof SqlBasicCall) {
+        sqlBasicCall = (SqlBasicCall) node2;
+      }
+      if (node1 instanceof SqlNodeList) {
+        list = (SqlNodeList) node1;
+      } else if (node2 instanceof SqlNodeList) {
+        list = (SqlNodeList) node2;
+      }
+
+      if (sqlBasicCall != null && list != null
+          && (sqlBasicCall.getOperator().getKind() == SqlKind.PERCENTILE_CONT

Review comment:
       Is it necessary to hard-code the SqlKind values here? Operators should 
validate based on their properties (e.g. {{SqlAggFunction.requiresOrder}}). 
Let's discuss in JIRA.




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


Reply via email to