mchades commented on code in PR #9560:
URL: https://github.com/apache/gravitino/pull/9560#discussion_r2667786393
##########
core/src/main/java/org/apache/gravitino/catalog/ManagedFunctionOperations.java:
##########
@@ -117,21 +159,448 @@ public Function registerFunction(
FunctionColumn[] returnColumns,
FunctionDefinition[] definitions)
throws NoSuchSchemaException, FunctionAlreadyExistsException {
- // TODO: Implement when FunctionEntity is available
- throw new UnsupportedOperationException(
- "registerFunction for table-valued functions: FunctionEntity not yet
implemented");
+ return doRegisterFunction(
+ ident, comment, FunctionType.TABLE, deterministic, null,
returnColumns, definitions);
}
@Override
public Function alterFunction(NameIdentifier ident, FunctionChange...
changes)
throws NoSuchFunctionException, IllegalArgumentException {
- // TODO: Implement when FunctionEntity is available
- throw new UnsupportedOperationException("alterFunction: FunctionEntity not
yet implemented");
+ try {
+ return store.update(
+ ident,
+ FunctionEntity.class,
+ Entity.EntityType.FUNCTION,
+ oldEntity -> applyChanges(oldEntity, changes));
+
+ } catch (NoSuchEntityException e) {
+ throw new NoSuchFunctionException(e, "Function %s does not exist",
ident);
+ } catch (EntityAlreadyExistsException e) {
+ throw new IllegalArgumentException("Failed to alter function " + ident,
e);
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to alter function " + ident, e);
+ }
}
@Override
public boolean dropFunction(NameIdentifier ident) {
- // TODO: Implement when FunctionEntity is available
- throw new UnsupportedOperationException("dropFunction: FunctionEntity not
yet implemented");
+ try {
+ return store.delete(ident, Entity.EntityType.FUNCTION);
+ } catch (NoSuchEntityException e) {
+ return false;
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to drop function " + ident, e);
+ }
+ }
+
+ /**
+ * Converts a function identifier to a versioned identifier. The versioned
identifier uses the
+ * version number as the name to allow the store to retrieve specific
versions.
+ *
+ * @param ident The function identifier.
+ * @param version The version number, or {@link
FunctionEntity#LATEST_VERSION} for the latest.
+ * @return The versioned identifier.
+ */
+ private NameIdentifier toVersionedIdent(NameIdentifier ident, int version) {
+ return NameIdentifier.of(
+ ident.namespace().level(0),
+ ident.namespace().level(1),
+ ident.namespace().level(2),
+ ident.name(),
+ String.valueOf(version));
Review Comment:
The storage will do the check in the next PR
--
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]