You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2022/08/08 13:26:31 UTC

[GitHub] [iceberg] wuwenchi commented on a diff in pull request #5120: Flink: add sql partition functions

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


##########
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:
   About the `system` database, is this database just a logical database? Is it that users cannot create tables under this library? In sql, is it not possible to execute `use iceberg_catalog.system`?  Because this is related to the list of functions, if we you cannot use `use system` to switch the currently used database, we cannot list functions under the `system`, because `show functions` can only display the functions under the current database.
   



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org