in zetasql-toolkit-core/src/main/java/com/google/zetasql/toolkit/ZetaSQLToolkitAnalyzer.java [329:374]
private void validateProcedureAndTVFReferences(ASTStatement parsedStatement) {
parsedStatement.accept(
new ParseTreeVisitor() {
public void visit(ASTCallStatement callStatement) {
List<String> procedureNames =
callStatement.getProcedureName().getNames().stream()
.map(ASTIdentifier::getIdString)
.collect(Collectors.toList());
if (procedureNames.size() > 1) {
String foundProcedureName =
procedureNames.stream()
.map(name -> "`" + name + "`")
.collect(Collectors.joining("."));
String expectedProcedureName = "`" + String.join(".", procedureNames) + "`";
String message =
String.format(
"Procedures in CALL statements should be fully quoted. Expected %s, found %s.",
expectedProcedureName, foundProcedureName);
throw new AnalysisException(message);
}
}
public void visit(ASTTVF astTvf) {
List<String> tvfNames =
astTvf.getName().getNames().stream()
.map(ASTIdentifier::getIdString)
.collect(Collectors.toList());
if (tvfNames.size() > 1) {
String foundTvfName =
tvfNames.stream()
.map(name -> "`" + name + "`")
.collect(Collectors.joining("."));
String expectedTvfName = "`" + String.join(".", tvfNames) + "`";
String message =
String.format(
"TVF calls should be fully quoted. Expected %s, found %s.",
expectedTvfName, foundTvfName);
throw new AnalysisException(message);
}
}
});
}