mumuhhh commented on code in PR #24600: URL: https://github.com/apache/flink/pull/24600#discussion_r1600843684
########## flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/utils/DynamicPartitionPruningUtils.java: ########## @@ -236,6 +238,9 @@ private void setTables(ContextResolvedTable catalogTable) { tables.add(catalogTable); } else { for (ContextResolvedTable thisTable : new ArrayList<>(tables)) { + if (tables.contains(catalogTable)) { Review Comment: > I think we can use a boolean flag to check here, then we don't need to call contains method every time, it is O(N) time complexity. > > ``` > boolean hasAdded = false; > for (ContextResolvedTable thisTable : new ArrayList<>(tables)) { > if (hasAdded) { > break; > } > if (!thisTable.getIdentifier().equals(catalogTable.getIdentifier())) { > tables.add(catalogTable); > hasAdded = true; > } > } > ``` I think we should modify the traversal logic. ``` boolean hasAdded = false; for (ContextResolvedTable thisTable : new ArrayList<>(tables)) { if (thisTable.getIdentifier().equals(catalogTable.getIdentifier())) { hasAdded = true; break; } } if (!hasAdded) { tables.add(catalogTable); } ``` -- 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: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org