walterddr commented on a change in pull request #8158: URL: https://github.com/apache/pinot/pull/8158#discussion_r806365391
########## File path: pinot-common/src/main/java/org/apache/pinot/sql/parsers/CalciteSqlParser.java ########## @@ -710,14 +711,18 @@ private static Expression compileFunctionExpression(SqlBasicCall functionNode) { compilePathExpression(functionName, functionNode, path); return RequestUtils.getIdentifierExpression(path.toString()); } + if ((functionNode.getFunctionQuantifier() != null) && ("DISTINCT".equals( + functionNode.getFunctionQuantifier().toString()))) { + functionName = "DISTINCTCOUNT"; Review comment: Ran it with some test and i think the best way to handle it is to replace with the following. ```suggestion functionName = "DISTINCT" + functionName; ``` After that SUM(DISTINCT col1) at least can compile correctly but not execute, otherwise it will compute out a plan exactly the same as COUNT(DISTINCT col1) and returns a result (which clearly is not what we wanted) ########## File path: pinot-common/src/main/java/org/apache/pinot/sql/parsers/CalciteSqlParser.java ########## @@ -710,14 +711,18 @@ private static Expression compileFunctionExpression(SqlBasicCall functionNode) { compilePathExpression(functionName, functionNode, path); return RequestUtils.getIdentifierExpression(path.toString()); } + if ((functionNode.getFunctionQuantifier() != null) && ("DISTINCT".equals( + functionNode.getFunctionQuantifier().toString()))) { + functionName = "DISTINCTCOUNT"; Review comment: Ran it with some test and i think the best way to handle it is to replace with the following. ```suggestion functionName = "DISTINCT" + functionName; ``` After that `SUM(DISTINCT col1)` at least can compile correctly in parser and successfully error out during execute, otherwise it will compute out a plan exactly the same as `COUNT(DISTINCT col1)` and returns a result (which clearly is not what we wanted) -- 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: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org