wuwenchi commented on code in PR #5120:
URL: https://github.com/apache/iceberg/pull/5120#discussion_r922956343
##########
flink/v1.15/flink/src/main/java/org/apache/iceberg/flink/FlinkCatalog.java:
##########
@@ -161,19 +167,33 @@ public List<String> listDatabases() throws
CatalogException {
.collect(Collectors.toList());
}
+ public void registerPartitionFunction(String databaseName) {
+ partitionFunctions.putIfAbsent(databaseName + ".buckets",
+ new CatalogFunctionImpl(PartitionTransformUdf.Bucket.class.getName(),
FunctionLanguage.JAVA));
+ partitionFunctions.putIfAbsent(databaseName + ".truncates",
+ new
CatalogFunctionImpl(PartitionTransformUdf.Truncate.class.getName(),
FunctionLanguage.JAVA));
+ }
+
+ public void deregisterPartitionFunction(String databaseName) {
+ partitionFunctions.remove(databaseName + ".buckets");
+ partitionFunctions.remove(databaseName + ".truncates");
+ }
+
Review Comment:
If we register the function under the database, we need to first get the
database where the user is currently located. When the user enters `use
database` or `create database` in sql, some interfaces will be called. If the
database exists, we can register the function under the specified database.
But there is a problem here, as long as the database actually exists, even
if the iceberg table does not exist in the database, these functions will be
registered. This database may be a hive database, the user may have specified
the wrong database, resulting in the use of a wrong database, but we will still
register these functions under this database, because we cannot judge whether
this database is the iceberg table, or under the database, there are not only
iceberg tables, but also hive tables.
My idea is that since we can't distinguish whether there is an iceberg table
under the current database, when the user specifies a database, these functions
can be registered. Or, is there a good way to distinguish the above cases?
--
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]