Jackie-Jiang commented on a change in pull request #4216: PQL -> SQL enhancement - phase 1 - new Pinot Query Struct URL: https://github.com/apache/incubator-pinot/pull/4216#discussion_r290995380
########## File path: pinot-common/src/main/java/org/apache/pinot/common/request/transform/TransformExpressionTree.java ########## @@ -75,34 +104,27 @@ public static String getStandardExpression(AstNode astNode) { } } - // Enum for expression represented by the tree. - public enum ExpressionType { - FUNCTION, IDENTIFIER, LITERAL - } - - private final ExpressionType _expressionType; - private final String _value; - private final List<TransformExpressionTree> _children; - - public TransformExpressionTree(AstNode root) { - if (root instanceof FunctionCallAstNode) { - _expressionType = ExpressionType.FUNCTION; - _value = ((FunctionCallAstNode) root).getName().toLowerCase(); - _children = new ArrayList<>(); - for (AstNode child : root.getChildren()) { - _children.add(new TransformExpressionTree(child)); + public static Expression getExpression(AstNode astNode) { + if (astNode instanceof IdentifierAstNode) { + // Column name + return RequestUtils.getIdentifierExpression(((IdentifierAstNode) astNode).getName()); + } else if (astNode instanceof FunctionCallAstNode) { + // Function expression + Expression expression = + RequestUtils.getFunctionExpression(((FunctionCallAstNode) astNode).getName()); + Function func = expression.getFunctionCall(); + if (astNode.getChildren() != null) { + for (AstNode child : astNode.getChildren()) { + func.addToOperands(getExpression(child)); + } } - } else if (root instanceof IdentifierAstNode) { - _expressionType = ExpressionType.IDENTIFIER; - _value = ((IdentifierAstNode) root).getName(); - _children = null; - } else if (root instanceof LiteralAstNode) { - _expressionType = ExpressionType.LITERAL; - _value = ((LiteralAstNode) root).getValueAsString(); - _children = null; + return expression; + } else if (astNode instanceof LiteralAstNode) { + return RequestUtils.getLiteralExpression(((LiteralAstNode) astNode)); + } else if (astNode instanceof PredicateAstNode) { + return ((PredicateAstNode) astNode).buildFilterExpression(); } else { - throw new IllegalArgumentException( - "Illegal AstNode type for TransformExpressionTree: " + root.getClass().getName()); + throw new IllegalStateException("Cannot get standard expression from " + astNode.getClass().getSimpleName()); Review comment: remove "standard" ---------------------------------------------------------------- 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 With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org