mayankshriv commented on a change in pull request #5513:
URL: https://github.com/apache/incubator-pinot/pull/5513#discussion_r436764713



##########
File path: 
pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/BaseBrokerRequestHandler.java
##########
@@ -435,6 +455,116 @@ static void handleQueryLimitOverride(BrokerRequest 
brokerRequest, int queryLimit
     }
   }
 
+  /**
+   * Check if a SQL parsed BrokerRequest is a literal only query.
+   * @param brokerRequest
+   * @return true if this query selects only Literals
+   *
+   */
+  @VisibleForTesting
+  static boolean isLiteralOnlyQuery(BrokerRequest brokerRequest) {
+    if (brokerRequest.getPinotQuery() != null) {

Review comment:
       Would be good to state in the PR description that this feature is only 
supported for SQL mode.

##########
File path: 
pinot-common/src/main/java/org/apache/pinot/sql/parsers/CalciteSqlParser.java
##########
@@ -676,14 +678,25 @@ protected static Expression 
invokeCompileTimeFunctionExpression(Expression funcE
       try {
         FunctionInvoker invoker = new FunctionInvoker(functionInfo);
         Object result = invoker.process(arguments);
-        if (result instanceof String) {
-          result = String.format("'%s'", result);
-        }
         return RequestUtils.getLiteralExpression(result);
       } catch (Exception e) {
         throw new SqlCompilationException(new 
IllegalArgumentException("Unsupported function - " + funcName, e));
       }
     }
     return funcExpr;
   }
+
+  public static boolean isLiteralOnlyExpression(Expression e) {
+    if (e.getType() == ExpressionType.LITERAL) {
+      return true;
+    }
+    if (e.getType() == ExpressionType.FUNCTION) {
+      Function functionCall = e.getFunctionCall();
+      if (functionCall.getOperator().equalsIgnoreCase(SqlKind.AS.toString())) {

Review comment:
       Does this work only with `AS`?




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

Reply via email to