You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gravitino.apache.org by "mchades (via GitHub)" <gi...@apache.org> on 2026/01/24 02:36:06 UTC
[PR] [#9529] feat(server): Add server-side REST interface for UDFs (part-2) [gravitino]
mchades opened a new pull request, #9794:
URL: https://github.com/apache/gravitino/pull/9794
### What changes were proposed in this pull request?
Changes include:
- Add FunctionOperations REST endpoint with register, get, update, delete operations
- Add exception handlers for function-related errors
- Add comprehensive unit tests for all new components
### Why are the changes needed?
Fix: #9529
### Does this PR introduce _any_ user-facing change?
no
### How was this patch tested?
tests added
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#9529] feat(server): Add server-side REST interface for UDFs (part-2) [gravitino]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #9794:
URL: https://github.com/apache/gravitino/pull/9794#discussion_r2728525265
##########
server/src/main/java/org/apache/gravitino/server/web/rest/FunctionOperations.java:
##########
@@ -0,0 +1,278 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.server.web.rest;
+
+import com.codahale.metrics.annotation.ResponseMetered;
+import com.codahale.metrics.annotation.Timed;
+import java.util.Arrays;
+import javax.inject.Inject;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.Namespace;
+import org.apache.gravitino.catalog.FunctionDispatcher;
+import org.apache.gravitino.dto.function.FunctionColumnDTO;
+import org.apache.gravitino.dto.function.FunctionDTO;
+import org.apache.gravitino.dto.function.FunctionDefinitionDTO;
+import org.apache.gravitino.dto.requests.FunctionRegisterRequest;
+import org.apache.gravitino.dto.requests.FunctionUpdateRequest;
+import org.apache.gravitino.dto.requests.FunctionUpdatesRequest;
+import org.apache.gravitino.dto.responses.DropResponse;
+import org.apache.gravitino.dto.responses.EntityListResponse;
+import org.apache.gravitino.dto.responses.FunctionListResponse;
+import org.apache.gravitino.dto.responses.FunctionResponse;
+import org.apache.gravitino.dto.util.DTOConverters;
+import org.apache.gravitino.function.Function;
+import org.apache.gravitino.function.FunctionChange;
+import org.apache.gravitino.function.FunctionColumn;
+import org.apache.gravitino.function.FunctionDefinition;
+import org.apache.gravitino.function.FunctionType;
+import org.apache.gravitino.metrics.MetricNames;
+import org.apache.gravitino.rel.types.Type;
+import org.apache.gravitino.server.web.Utils;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+import org.apache.gravitino.utils.NamespaceUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/** REST operations for function management. */
+@Path("metalakes/{metalake}/catalogs/{catalog}/schemas/{schema}/functions")
+public class FunctionOperations {
+
+ private static final Logger LOG = LoggerFactory.getLogger(FunctionOperations.class);
+
+ private final FunctionDispatcher dispatcher;
+
+ @Context private HttpServletRequest httpRequest;
+
+ @Inject
+ public FunctionOperations(FunctionDispatcher dispatcher) {
+ this.dispatcher = dispatcher;
+ }
+
+ // TODO: Add authorization support for function operations
+ @GET
+ @Produces("application/vnd.gravitino.v1+json")
+ @Timed(name = "list-function." + MetricNames.HTTP_PROCESS_DURATION, absolute = true)
+ @ResponseMetered(name = "list-function", absolute = true)
+ public Response listFunctions(
+ @PathParam("metalake") String metalake,
+ @PathParam("catalog") String catalog,
+ @PathParam("schema") String schema,
+ @QueryParam("details") @DefaultValue("false") boolean details) {
Review Comment:
These function REST endpoints currently lack any `@AuthorizationExpression` (or related authorization) annotations, so when `GravitinoInterceptionService` intercepts these methods it will skip all metadata authorization checks and `AuthorizationUtils.checkCurrentUser`, effectively exposing list/get/register/alter/drop of functions without the same access control applied to tables, models, schemas, etc. To align with the existing security model, please add appropriate authorization annotations for all function operations (e.g., similar to `TableOperations` and `ModelOperations`) so that function metadata and mutations are consistently subject to authorization before this API is exposed.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#9529] feat(server): Add server-side REST interface for UDFs (part-2) [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao merged PR #9794:
URL: https://github.com/apache/gravitino/pull/9794
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#9529] feat(server): Add server-side REST interface for UDFs (part-2) [gravitino]
Posted by "mchades (via GitHub)" <gi...@apache.org>.
mchades commented on code in PR #9794:
URL: https://github.com/apache/gravitino/pull/9794#discussion_r2730016705
##########
server/src/main/java/org/apache/gravitino/server/web/rest/FunctionOperations.java:
##########
@@ -0,0 +1,278 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.server.web.rest;
+
+import com.codahale.metrics.annotation.ResponseMetered;
+import com.codahale.metrics.annotation.Timed;
+import java.util.Arrays;
+import javax.inject.Inject;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.Namespace;
+import org.apache.gravitino.catalog.FunctionDispatcher;
+import org.apache.gravitino.dto.function.FunctionColumnDTO;
+import org.apache.gravitino.dto.function.FunctionDTO;
+import org.apache.gravitino.dto.function.FunctionDefinitionDTO;
+import org.apache.gravitino.dto.requests.FunctionRegisterRequest;
+import org.apache.gravitino.dto.requests.FunctionUpdateRequest;
+import org.apache.gravitino.dto.requests.FunctionUpdatesRequest;
+import org.apache.gravitino.dto.responses.DropResponse;
+import org.apache.gravitino.dto.responses.EntityListResponse;
+import org.apache.gravitino.dto.responses.FunctionListResponse;
+import org.apache.gravitino.dto.responses.FunctionResponse;
+import org.apache.gravitino.dto.util.DTOConverters;
+import org.apache.gravitino.function.Function;
+import org.apache.gravitino.function.FunctionChange;
+import org.apache.gravitino.function.FunctionColumn;
+import org.apache.gravitino.function.FunctionDefinition;
+import org.apache.gravitino.function.FunctionType;
+import org.apache.gravitino.metrics.MetricNames;
+import org.apache.gravitino.rel.types.Type;
+import org.apache.gravitino.server.web.Utils;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+import org.apache.gravitino.utils.NamespaceUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/** REST operations for function management. */
+@Path("metalakes/{metalake}/catalogs/{catalog}/schemas/{schema}/functions")
+public class FunctionOperations {
+
+ private static final Logger LOG = LoggerFactory.getLogger(FunctionOperations.class);
+
+ private final FunctionDispatcher dispatcher;
+
+ @Context private HttpServletRequest httpRequest;
+
+ @Inject
+ public FunctionOperations(FunctionDispatcher dispatcher) {
+ this.dispatcher = dispatcher;
+ }
+
+ // TODO: Add authorization support for function operations
+ @GET
+ @Produces("application/vnd.gravitino.v1+json")
+ @Timed(name = "list-function." + MetricNames.HTTP_PROCESS_DURATION, absolute = true)
+ @ResponseMetered(name = "list-function", absolute = true)
+ public Response listFunctions(
+ @PathParam("metalake") String metalake,
+ @PathParam("catalog") String catalog,
+ @PathParam("schema") String schema,
+ @QueryParam("details") @DefaultValue("false") boolean details) {
+ try {
+ LOG.info("Received list functions request for schema: {}.{}.{}", metalake, catalog, schema);
+ return Utils.doAs(
+ httpRequest,
+ () -> {
+ Namespace namespace = NamespaceUtil.ofFunction(metalake, catalog, schema);
+ if (!details) {
+ NameIdentifier[] identifiers = dispatcher.listFunctions(namespace);
+ LOG.info(
+ "List {} function names under schema: {}.{}.{}",
+ identifiers.length,
+ metalake,
+ catalog,
+ schema);
+ return Utils.ok(new EntityListResponse(identifiers));
+ }
+
+ Function[] functions = dispatcher.listFunctionInfos(namespace);
+ FunctionDTO[] functionDTOs =
+ Arrays.stream(functions)
+ .map(DTOConverters::toDTO)
+ .toList()
+ .toArray(new FunctionDTO[0]);
+ LOG.info(
+ "List {} function definitions under schema: {}.{}.{}",
+ functionDTOs.length,
+ metalake,
+ catalog,
+ schema);
+ return Utils.ok(new FunctionListResponse(functionDTOs));
+ });
+ } catch (Exception e) {
+ return ExceptionHandlers.handleFunctionException(OperationType.LIST, "", schema, e);
+ }
+ }
+
+ @POST
+ @Produces("application/vnd.gravitino.v1+json")
+ @Timed(name = "register-function." + MetricNames.HTTP_PROCESS_DURATION, absolute = true)
+ @ResponseMetered(name = "register-function", absolute = true)
+ public Response registerFunction(
+ @PathParam("metalake") String metalake,
+ @PathParam("catalog") String catalog,
+ @PathParam("schema") String schema,
+ FunctionRegisterRequest request) {
+ LOG.info(
+ "Received register function request: {}.{}.{}.{}",
+ metalake,
+ catalog,
+ schema,
+ request.getName());
+ try {
+ return Utils.doAs(
+ httpRequest,
+ () -> {
+ request.validate();
+ NameIdentifier ident =
+ NameIdentifierUtil.ofFunction(metalake, catalog, schema, request.getName());
+
+ FunctionDefinition[] definitions =
+ Arrays.stream(request.getDefinitions())
+ .map(FunctionDefinitionDTO::toFunctionDefinition)
+ .toArray(FunctionDefinition[]::new);
+
+ Function function;
+ if (request.getFunctionType() == FunctionType.TABLE) {
+ FunctionColumn[] returnColumns =
+ Arrays.stream(request.getReturnColumns())
+ .map(FunctionColumnDTO::toFunctionColumn)
+ .toArray(FunctionColumn[]::new);
+ function =
+ dispatcher.registerFunction(
+ ident,
+ request.getComment(),
+ request.isDeterministic(),
+ returnColumns,
+ definitions);
+ } else {
+ Type returnType = request.getReturnType();
+ function =
+ dispatcher.registerFunction(
+ ident,
+ request.getComment(),
+ request.getFunctionType(),
+ request.isDeterministic(),
+ returnType,
+ definitions);
+ }
+
+ Response response = Utils.ok(new FunctionResponse(DTOConverters.toDTO(function)));
+ LOG.info(
+ "Function registered: {}.{}.{}.{}", metalake, catalog, schema, request.getName());
+ return response;
+ });
+ } catch (Exception e) {
+ return ExceptionHandlers.handleFunctionException(
+ OperationType.CREATE, request.getName(), schema, e);
Review Comment:
fixed
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#9529] feat(server): Add server-side REST interface for UDFs (part-2) [gravitino]
Posted by "mchades (via GitHub)" <gi...@apache.org>.
mchades commented on code in PR #9794:
URL: https://github.com/apache/gravitino/pull/9794#discussion_r2729987238
##########
server/src/main/java/org/apache/gravitino/server/web/rest/FunctionOperations.java:
##########
@@ -0,0 +1,278 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.server.web.rest;
+
+import com.codahale.metrics.annotation.ResponseMetered;
+import com.codahale.metrics.annotation.Timed;
+import java.util.Arrays;
+import javax.inject.Inject;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.Namespace;
+import org.apache.gravitino.catalog.FunctionDispatcher;
+import org.apache.gravitino.dto.function.FunctionColumnDTO;
+import org.apache.gravitino.dto.function.FunctionDTO;
+import org.apache.gravitino.dto.function.FunctionDefinitionDTO;
+import org.apache.gravitino.dto.requests.FunctionRegisterRequest;
+import org.apache.gravitino.dto.requests.FunctionUpdateRequest;
+import org.apache.gravitino.dto.requests.FunctionUpdatesRequest;
+import org.apache.gravitino.dto.responses.DropResponse;
+import org.apache.gravitino.dto.responses.EntityListResponse;
+import org.apache.gravitino.dto.responses.FunctionListResponse;
+import org.apache.gravitino.dto.responses.FunctionResponse;
+import org.apache.gravitino.dto.util.DTOConverters;
+import org.apache.gravitino.function.Function;
+import org.apache.gravitino.function.FunctionChange;
+import org.apache.gravitino.function.FunctionColumn;
+import org.apache.gravitino.function.FunctionDefinition;
+import org.apache.gravitino.function.FunctionType;
+import org.apache.gravitino.metrics.MetricNames;
+import org.apache.gravitino.rel.types.Type;
+import org.apache.gravitino.server.web.Utils;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+import org.apache.gravitino.utils.NamespaceUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/** REST operations for function management. */
+@Path("metalakes/{metalake}/catalogs/{catalog}/schemas/{schema}/functions")
+public class FunctionOperations {
+
+ private static final Logger LOG = LoggerFactory.getLogger(FunctionOperations.class);
+
+ private final FunctionDispatcher dispatcher;
+
+ @Context private HttpServletRequest httpRequest;
+
+ @Inject
+ public FunctionOperations(FunctionDispatcher dispatcher) {
+ this.dispatcher = dispatcher;
+ }
+
+ // TODO: Add authorization support for function operations
+ @GET
+ @Produces("application/vnd.gravitino.v1+json")
+ @Timed(name = "list-function." + MetricNames.HTTP_PROCESS_DURATION, absolute = true)
+ @ResponseMetered(name = "list-function", absolute = true)
+ public Response listFunctions(
+ @PathParam("metalake") String metalake,
+ @PathParam("catalog") String catalog,
+ @PathParam("schema") String schema,
+ @QueryParam("details") @DefaultValue("false") boolean details) {
Review Comment:
A todo was left there.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#9529] feat(server): Add server-side REST interface for UDFs (part-2) [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on code in PR #9794:
URL: https://github.com/apache/gravitino/pull/9794#discussion_r2728534340
##########
server/src/main/java/org/apache/gravitino/server/web/rest/FunctionOperations.java:
##########
@@ -0,0 +1,278 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.server.web.rest;
+
+import com.codahale.metrics.annotation.ResponseMetered;
+import com.codahale.metrics.annotation.Timed;
+import java.util.Arrays;
+import javax.inject.Inject;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.Namespace;
+import org.apache.gravitino.catalog.FunctionDispatcher;
+import org.apache.gravitino.dto.function.FunctionColumnDTO;
+import org.apache.gravitino.dto.function.FunctionDTO;
+import org.apache.gravitino.dto.function.FunctionDefinitionDTO;
+import org.apache.gravitino.dto.requests.FunctionRegisterRequest;
+import org.apache.gravitino.dto.requests.FunctionUpdateRequest;
+import org.apache.gravitino.dto.requests.FunctionUpdatesRequest;
+import org.apache.gravitino.dto.responses.DropResponse;
+import org.apache.gravitino.dto.responses.EntityListResponse;
+import org.apache.gravitino.dto.responses.FunctionListResponse;
+import org.apache.gravitino.dto.responses.FunctionResponse;
+import org.apache.gravitino.dto.util.DTOConverters;
+import org.apache.gravitino.function.Function;
+import org.apache.gravitino.function.FunctionChange;
+import org.apache.gravitino.function.FunctionColumn;
+import org.apache.gravitino.function.FunctionDefinition;
+import org.apache.gravitino.function.FunctionType;
+import org.apache.gravitino.metrics.MetricNames;
+import org.apache.gravitino.rel.types.Type;
+import org.apache.gravitino.server.web.Utils;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+import org.apache.gravitino.utils.NamespaceUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/** REST operations for function management. */
+@Path("metalakes/{metalake}/catalogs/{catalog}/schemas/{schema}/functions")
+public class FunctionOperations {
+
+ private static final Logger LOG = LoggerFactory.getLogger(FunctionOperations.class);
+
+ private final FunctionDispatcher dispatcher;
+
+ @Context private HttpServletRequest httpRequest;
+
+ @Inject
+ public FunctionOperations(FunctionDispatcher dispatcher) {
+ this.dispatcher = dispatcher;
+ }
+
+ // TODO: Add authorization support for function operations
+ @GET
+ @Produces("application/vnd.gravitino.v1+json")
+ @Timed(name = "list-function." + MetricNames.HTTP_PROCESS_DURATION, absolute = true)
+ @ResponseMetered(name = "list-function", absolute = true)
+ public Response listFunctions(
+ @PathParam("metalake") String metalake,
+ @PathParam("catalog") String catalog,
+ @PathParam("schema") String schema,
+ @QueryParam("details") @DefaultValue("false") boolean details) {
+ try {
+ LOG.info("Received list functions request for schema: {}.{}.{}", metalake, catalog, schema);
+ return Utils.doAs(
+ httpRequest,
+ () -> {
+ Namespace namespace = NamespaceUtil.ofFunction(metalake, catalog, schema);
+ if (!details) {
+ NameIdentifier[] identifiers = dispatcher.listFunctions(namespace);
+ LOG.info(
+ "List {} function names under schema: {}.{}.{}",
+ identifiers.length,
+ metalake,
+ catalog,
+ schema);
+ return Utils.ok(new EntityListResponse(identifiers));
+ }
+
+ Function[] functions = dispatcher.listFunctionInfos(namespace);
+ FunctionDTO[] functionDTOs =
+ Arrays.stream(functions)
+ .map(DTOConverters::toDTO)
+ .toList()
+ .toArray(new FunctionDTO[0]);
+ LOG.info(
+ "List {} function definitions under schema: {}.{}.{}",
+ functionDTOs.length,
+ metalake,
+ catalog,
+ schema);
+ return Utils.ok(new FunctionListResponse(functionDTOs));
+ });
+ } catch (Exception e) {
+ return ExceptionHandlers.handleFunctionException(OperationType.LIST, "", schema, e);
+ }
+ }
+
+ @POST
+ @Produces("application/vnd.gravitino.v1+json")
+ @Timed(name = "register-function." + MetricNames.HTTP_PROCESS_DURATION, absolute = true)
+ @ResponseMetered(name = "register-function", absolute = true)
+ public Response registerFunction(
+ @PathParam("metalake") String metalake,
+ @PathParam("catalog") String catalog,
+ @PathParam("schema") String schema,
+ FunctionRegisterRequest request) {
+ LOG.info(
+ "Received register function request: {}.{}.{}.{}",
+ metalake,
+ catalog,
+ schema,
+ request.getName());
+ try {
+ return Utils.doAs(
+ httpRequest,
+ () -> {
+ request.validate();
+ NameIdentifier ident =
+ NameIdentifierUtil.ofFunction(metalake, catalog, schema, request.getName());
+
+ FunctionDefinition[] definitions =
+ Arrays.stream(request.getDefinitions())
+ .map(FunctionDefinitionDTO::toFunctionDefinition)
+ .toArray(FunctionDefinition[]::new);
+
+ Function function;
+ if (request.getFunctionType() == FunctionType.TABLE) {
+ FunctionColumn[] returnColumns =
+ Arrays.stream(request.getReturnColumns())
+ .map(FunctionColumnDTO::toFunctionColumn)
+ .toArray(FunctionColumn[]::new);
+ function =
+ dispatcher.registerFunction(
+ ident,
+ request.getComment(),
+ request.isDeterministic(),
+ returnColumns,
+ definitions);
+ } else {
+ Type returnType = request.getReturnType();
+ function =
+ dispatcher.registerFunction(
+ ident,
+ request.getComment(),
+ request.getFunctionType(),
+ request.isDeterministic(),
+ returnType,
+ definitions);
+ }
+
+ Response response = Utils.ok(new FunctionResponse(DTOConverters.toDTO(function)));
+ LOG.info(
+ "Function registered: {}.{}.{}.{}", metalake, catalog, schema, request.getName());
+ return response;
+ });
+ } catch (Exception e) {
+ return ExceptionHandlers.handleFunctionException(
+ OperationType.CREATE, request.getName(), schema, e);
Review Comment:
Should you use "REGISTER" here?
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org