fx19880617 commented on a change in pull request #5406: URL: https://github.com/apache/incubator-pinot/pull/5406#discussion_r427744550
########## File path: pinot-common/src/main/java/org/apache/pinot/sql/parsers/CalciteSqlParser.java ########## @@ -615,7 +618,47 @@ private static Expression toExpression(SqlNode node) { funcExpr.getFunctionCall().addToOperands(toExpression(child)); } } + + if (FunctionDefinitionRegistry.isScalarFunc(funcName) && isCompileTimeEvaluationPossible(funcExpr)) { + + ScalarFunctionType scalarFunctionType = ScalarFunctionType.getScalarFunctionType(funcName); + switch (scalarFunctionType) { + case NOW: + funcExpr = RequestUtils.getLiteralExpression(System.currentTimeMillis()); + break; + case FORMAT_DATETIME: + //DATETIME_FORMAT ('2020-01-01', 'yyyy-MM-dd') + String input = funcExpr.getFunctionCall().getOperands().get(0).getLiteral().getStringValue(); + String format = funcExpr.getFunctionCall().getOperands().get(1).getLiteral().getStringValue(); + long output = DateTimeFormat.forPattern(format).parseMillis(input); + funcExpr = RequestUtils.getLiteralExpression(output); Review comment: Added support for eval function of functions as long as all the recursive params are literal. ---------------------------------------------------------------- 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: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org