LuciferYang commented on code in PR #37843: URL: https://github.com/apache/spark/pull/37843#discussion_r972520010
########## sql/catalyst/src/main/java/org/apache/spark/sql/connector/expressions/Expression.java: ########## @@ -44,7 +46,12 @@ public interface Expression { * List of fields or columns that are referenced by this expression. */ default NamedReference[] references() { - return Arrays.stream(children()).map(e -> e.references()) - .flatMap(Arrays::stream).distinct().toArray(NamedReference[]::new); + // SPARK-40398: Replace `Arrays.stream()...distinct()` + // to this for perf gain, the result order is not important. + Set<NamedReference> set = new HashSet<>(); + for (Expression e : children()) { + Collections.addAll(set, e.references()); + } + return set.toArray(new NamedReference[0]); Review Comment: [1a6a3c8](https://github.com/apache/spark/pull/37843/commits/1a6a3c89810a3aa9aa33c5e06109f242aa8ec2b0) -- 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: reviews-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org