himanshug commented on a change in pull request #7588: multi-value string column support for expressions URL: https://github.com/apache/incubator-druid/pull/7588#discussion_r291724317
########## File path: core/src/main/java/org/apache/druid/math/expr/Expr.java ########## @@ -348,21 +876,55 @@ public void visit(Visitor visitor) visitor.visit(this); } + @Override + public Expr visit(Shuttle shuttle) + { + Expr newLeft = left.visit(shuttle); + Expr newRight = right.visit(shuttle); + if (left != newLeft || right != newRight) { + return shuttle.visit(copy(newLeft, newRight)); + } + return shuttle.visit(this); + } + @Override public String toString() { - return "(" + op + " " + left + " " + right + ")"; + return StringUtils.format("(%s %s %s)", op, left, right); + } + + protected abstract BinaryOpExprBase copy(Expr left, Expr right); + + @Override + public BindingDetails analyzeInputs() + { + // currently all binary operators operate on scalar inputs + final Set<String> scalars = new HashSet<>(); + final String leftIdentifer = left.getIdentifierIfIdentifier(); + final String rightIdentifier = right.getIdentifierIfIdentifier(); + if (leftIdentifer != null) { + scalars.add(leftIdentifer); + } + if (rightIdentifier != null) { + scalars.add(rightIdentifier); + } + return left.analyzeInputs() + .merge(right.analyzeInputs()) + .mergeWithScalars(scalars); Review comment: Similar to UnaryExpr, this could also just return `return left.analyzeInputs().merge(right.analyzeInputs())` ? ---------------------------------------------------------------- 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...@druid.apache.org For additional commands, e-mail: commits-h...@druid.apache.org