rdblue commented on code in PR #5120:
URL: https://github.com/apache/iceberg/pull/5120#discussion_r939699655
##########
flink/v1.15/flink/src/main/java/org/apache/iceberg/flink/FlinkCatalog.java:
##########
@@ -162,20 +168,33 @@ public List<String> listDatabases() throws
CatalogException {
.collect(Collectors.toList());
}
+ private void registerPartitionFunction(String databaseName) {
+ functions.putIfAbsent(
+ new ObjectPath(databaseName,
PartitionTransformUdf.Bucket.FUNCTION_NAME),
+ new CatalogFunctionImpl(
+ PartitionTransformUdf.Bucket.class.getName(),
FunctionLanguage.JAVA));
+ functions.putIfAbsent(
+ new ObjectPath(databaseName,
PartitionTransformUdf.Truncate.FUNCTION_NAME),
+ new CatalogFunctionImpl(
+ PartitionTransformUdf.Truncate.class.getName(),
FunctionLanguage.JAVA));
+ }
+
@Override
public CatalogDatabase getDatabase(String databaseName)
throws DatabaseNotExistException, CatalogException {
if (asNamespaceCatalog == null) {
if (!getDefaultDatabase().equals(databaseName)) {
throw new DatabaseNotExistException(getName(), databaseName);
} else {
+ registerPartitionFunction(databaseName);
return new CatalogDatabaseImpl(Maps.newHashMap(), "");
}
} else {
try {
Map<String, String> metadata =
Maps.newHashMap(asNamespaceCatalog.loadNamespaceMetadata(toNamespace(databaseName)));
String comment = metadata.remove("comment");
+ registerPartitionFunction(databaseName);
Review Comment:
@wuwenchi, these functions should not be registered in every known database.
The problem before was not how you were tracking functions, it was the
behavior. You need to change the behavior.
Here's my last comment:
> The problem is that this is effectively registering the functions in every
database. Instead, choose one database where you want the functions to live.
For stored procedures, we use `system`. I think that's a good idea here.
Please remove the registration code that isn't needed and update the
function lookup and listing to only return these functions if the database is
`system`.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]