in bigquery-antipattern-recognition/src/main/java/com/google/zetasql/toolkit/antipattern/parser/visitors/IdentifyCTEsEvalMultipleTimesVisitor.java [116:129]
public String getResult() {
// Loop through all the entries in the count map.
for (Map.Entry<String, Integer> entry : cteCountMap.entrySet()) {
// Get the CTE name and its count.
String cteName = entry.getKey();
int count = entry.getValue();
// If the CTE count is greater than 1, add the suggestion message to the list.
if (count > 1) {
int lineNum = ZetaSQLStringParsingHelper.countLine(query, cteStartPositionMap.get(cteName));
result.add(String.format(MULTIPLE_CTE_SUGGESTION_MESSAGE, cteName, lineNum, count));
}
}
return result.stream().distinct().collect(Collectors.joining("\n"));
}