dawidwys commented on a change in pull request #10942: [FLINK-15487][table]
Allow registering FLIP-65 functions in TableEnvironment
URL: https://github.com/apache/flink/pull/10942#discussion_r373962137
##########
File path:
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/FunctionCatalog.java
##########
@@ -81,8 +85,283 @@ public void
setPlannerTypeInferenceUtil(PlannerTypeInferenceUtil plannerTypeInfe
this.plannerTypeInferenceUtil = plannerTypeInferenceUtil;
}
+ /**
+ * Registers a temporary system function.
+ */
+ public void registerTemporarySystemFunction(
+ String name,
+ FunctionDefinition definition,
+ boolean ignoreIfExists) {
+ final String normalizedName =
FunctionIdentifier.normalizeName(name);
+
+ if (definition instanceof UserDefinedFunction) {
+ try {
+
UserDefinedFunctionHelper.prepareInstance(config, (UserDefinedFunction)
definition);
+ } catch (Throwable t) {
+ throw new ValidationException(
+ String.format(
+ "Could not register temporary
system function '%s' due to implementation errors.",
+ name),
+ t);
+ }
+ }
+
+ if (!tempSystemFunctions.containsKey(normalizedName)) {
+ tempSystemFunctions.put(normalizedName, definition);
+ } else if (!ignoreIfExists) {
+ throw new ValidationException(
+ String.format(
+ "Could not register temporary system
function. A function named '%s' does already exist.",
+ name));
+ }
+ }
+
+ /**
+ * Drops a temporary system function. Returns true if a function was
dropped.
+ */
+ public boolean dropTemporarySystemFunction(
+ String name,
+ boolean ignoreIfNotExist) {
+ final String normalizedName =
FunctionIdentifier.normalizeName(name);
+ final FunctionDefinition definition =
tempSystemFunctions.remove(normalizedName);
+
+ if (definition == null && !ignoreIfNotExist) {
+ throw new ValidationException(
+ String.format(
+ "Could not drop temporary system
function. A function named '%s' doesn't exist.",
+ name));
+ }
+
+ return definition != null;
+ }
+
+ /**
+ * Registers a temporary catalog function.
+ */
+ public void registerTemporaryCatalogFunction(
+ UnresolvedIdentifier unresolvedIdentifier,
Review comment:
Created https://issues.apache.org/jira/browse/FLINK-15859
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services