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/06/23 23:55:16 UTC

[GitHub] [calcite] a-rafay commented on a change in pull request #2444: [CALCITE-4644] Added PERCENTILE_CONT and PERCENTILE_DISC functions in…

a-rafay commented on a change in pull request #2444:
URL: https://github.com/apache/calcite/pull/2444#discussion_r657532338



##########
File path: core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java
##########
@@ -1500,6 +1504,37 @@ private void handleOffsetFetch(@Nullable SqlNode offset, @Nullable SqlNode fetch
     return node;
   }
 
+  private void validatePercentileFunctions(SqlCall call) {
+    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() instanceof SqlBasicAggFunction) {
+        SqlBasicAggFunction agg = (SqlBasicAggFunction) sqlBasicCall.getOperator();
+        if (agg.isPercentile()) {
+          // Validate that Percentile function have a single ORDER BY expression
+          if (list.getList().size() != 1) {

Review comment:
       @julianhyde I am validating here that the order by clause must only have a single expression. Is there a way to validate the type of that expression? I spent some time but could not find a way to get the type from SqlNode. Or should this be done elsewhere?




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