in zetasql-toolkit-core/src/main/java/com/google/zetasql/toolkit/catalog/CatalogOperations.java [297:317]
public static void createTVFInCatalog(
SimpleCatalog catalog, String nameInCatalog, TVFInfo tvfInfo, CreateMode createMode) {
Preconditions.checkArgument(
tvfInfo.getOutputSchema().isPresent(), "Cannot create a a TVF without an output schema");
boolean alreadyExists = tvfExists(catalog, nameInCatalog);
TableValuedFunction tvf =
new FixedOutputSchemaTVF(
ImmutableList.of(nameInCatalog),
tvfInfo.getSignature(),
tvfInfo.getOutputSchema().get());
createResource(
nameInCatalog,
createMode,
"TVF",
alreadyExists,
/*creator=*/ () -> catalog.addTableValuedFunction(tvf),
/*deleter=*/ () -> deleteTVFFromCatalog(catalog, nameInCatalog));
}