wuwenchi commented on code in PR #5120:
URL: https://github.com/apache/iceberg/pull/5120#discussion_r940861936


##########
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:
   If it is a normal database, should we create it first when open catalog  
like the `default` database? Because if it is not created, the user cannot see 
the database, but can use the functions under the `system` database, which 
feels a little strange.



-- 
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]

Reply via email to