in zetasql-toolkit-bigquery/src/main/java/com/google/zetasql/toolkit/catalog/bigquery/FunctionResultTypeResolver.java [268:284]
public static TVFInfo resolveTVFOutputSchema(
TVFInfo tvfInfo, LanguageOptions languageOptions, SimpleCatalog catalog) {
if (tvfInfo.getOutputSchema().isPresent()) {
// The output schema is already known, no need to infer it
return tvfInfo;
}
// The return type is unknown, try to infer it
try {
TVFRelation newOutputSchema = inferTVFOutputSchema(tvfInfo, languageOptions, catalog);
return tvfInfo.toBuilder().setOutputSchema(newOutputSchema).build();
} catch (CouldNotInferFunctionReturnType err) {
throw new MissingFunctionResultType(tvfInfo.getNamePath(), err);
}
}