Skip to content

Conversation

@mchades
Copy link
Contributor

@mchades mchades commented Dec 26, 2025

What changes were proposed in this pull request?

This PR adds Java client support for UDF (User-Defined Function) operations, including:

  1. FunctionCatalog interface implementation in BaseSchemaCatalog: All catalog types now support function operations
  2. Client-side DTOs: Added FunctionDTO, FunctionParamDTO, FunctionDefinitionDTO, and FunctionImplDTO with subclasses for different implementation types (Java, Python, External)
  3. REST API client integration: Implemented REST client methods for:
    • registerFunction: Register a new function
    • getFunction: Get function by name (with optional version)
    • listFunctions: List all functions in a schema
    • dropFunction: Drop a function
    • alterFunction: Alter function with various changes (add/remove definition, add/update/remove impl, set/remove properties)
  4. Integration tests: Added comprehensive FunctionIT test class covering all function operations

Why are the changes needed?

This is part of the UDF feature implementation for Apache Gravitino. The Java client needs to support function operations so that users can programmatically manage UDFs through the Gravitino client library.

Fix: #9530

Does this PR introduce any user-facing change?

Yes, this PR introduces new user-facing APIs:

  • FunctionCatalog interface with methods: registerFunction, getFunction, listFunctions, dropFunction, alterFunction
  • All catalog types (Relational, Fileset, Messaging, Model) now implement FunctionCatalog

How was this patch tested?

  1. Added comprehensive integration tests in FunctionIT.java covering:
    • Register and get functions with different types (scalar, table, aggregate)
    • Register functions with multiple definitions and implementations (Java, Python, External)
    • Alter function operations (add/remove definition, add/update/remove impl)
    • Error cases (function not found, schema not found, function already exists, definition conflicts)
    • Drop function operations
    • List functions operations

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements comprehensive Java client support for User-Defined Function (UDF) operations in Apache Gravitino, enabling programmatic management of functions through the client library. The implementation includes REST API integration, DTOs for function metadata, core function operations, and database schema support for function persistence.

Key Changes:

  • Added function operations support to all catalog types through FunctionCatalog interface
  • Implemented REST endpoints for CRUD operations on functions
  • Created database schema and migration scripts for function metadata storage
  • Added comprehensive test coverage for function operations

Reviewed changes

Copilot reviewed 82 out of 82 changed files in this pull request and generated no comments.

Show a summary per file
File Description
server/src/test/java/org/apache/gravitino/server/web/rest/TestFunctionOperations.java Comprehensive REST API tests for function operations
server/src/main/java/org/apache/gravitino/server/web/rest/FunctionOperations.java REST endpoints implementation for function management
server/src/main/java/org/apache/gravitino/server/web/rest/ExceptionHandlers.java Added exception handling for function operations
scripts/postgresql/upgrade-1.1.0-to-1.2.0-postgresql.sql PostgreSQL schema upgrade script for function tables
scripts/mysql/upgrade-1.1.0-to-1.2.0-mysql.sql MySQL schema upgrade script for function tables
core/src/main/java/org/apache/gravitino/storage/relational/service/FunctionMetaService.java Service layer for function metadata persistence operations
core/src/main/java/org/apache/gravitino/meta/FunctionEntity.java Entity class representing function metadata
core/src/main/java/org/apache/gravitino/catalog/FunctionDispatcher.java Dispatcher interface for function operations
common/src/main/java/org/apache/gravitino/config/ConfigConstants.java Updated script version to 1.2.0 for schema migrations
Comments suppressed due to low confidence (14)

scripts/postgresql/upgrade-1.1.0-to-1.2.0-postgresql.sql:1

  • Corrected formatting error in SQL comment. Line 3 has an extra '--' at the end that should be removed to maintain consistent comment formatting throughout the file.
    scripts/postgresql/upgrade-1.1.0-to-1.2.0-postgresql.sql:1
  • Corrected parenthesis format in license text. The closing parenthesis should not have a period before it to match the Apache license header format.
    scripts/postgresql/schema-1.2.0-postgresql.sql:1
  • Corrected formatting error in SQL comment. Line 3 has an extra '--' at the end that should be removed to maintain consistent comment formatting throughout the file.
    scripts/postgresql/schema-1.2.0-postgresql.sql:1
  • Corrected parenthesis format in license text. The closing parenthesis should not have a period before it to match the Apache license header format.
    scripts/mysql/upgrade-1.1.0-to-1.2.0-mysql.sql:1
  • Corrected formatting error in SQL comment. Line 3 has an extra '--' at the end that should be removed to maintain consistent comment formatting throughout the file.
    scripts/mysql/upgrade-1.1.0-to-1.2.0-mysql.sql:1
  • Corrected parenthesis format in license text. The closing parenthesis should not have a period before it to match the Apache license header format.
    scripts/mysql/schema-1.2.0-mysql.sql:1
  • Corrected formatting error in SQL comment. Line 3 has an extra '--' at the end that should be removed to maintain consistent comment formatting throughout the file.
    scripts/mysql/schema-1.2.0-mysql.sql:1
  • Corrected parenthesis format in license text. The closing parenthesis should not have a period before it to match the Apache license header format.
    scripts/h2/upgrade-1.1.0-to-1.2.0-h2.sql:1
  • Corrected formatting error in SQL comment. Line 3 has an extra '--' at the end that should be removed to maintain consistent comment formatting throughout the file.
    scripts/h2/upgrade-1.1.0-to-1.2.0-h2.sql:1
  • Corrected parenthesis format in license text. The closing parenthesis should not have a period before it to match the Apache license header format.
    scripts/h2/schema-1.2.0-h2.sql:1
  • Corrected formatting error in SQL comment. Line 3 has an extra '--' at the end that should be removed to maintain consistent comment formatting throughout the file.
    scripts/h2/schema-1.2.0-h2.sql:1
  • Corrected parenthesis format in license text. The closing parenthesis should not have a period before it to match the Apache license header format.
    core/src/main/java/org/apache/gravitino/storage/relational/po/FunctionVersionPO.java:1
  • The private constructor lacks documentation explaining that it enforces the builder pattern usage. Consider adding a Javadoc comment explaining this design choice.
    core/src/main/java/org/apache/gravitino/storage/relational/po/FunctionPO.java:1
  • The private constructor lacks documentation explaining that it enforces the builder pattern usage. Consider adding a Javadoc comment explaining this design choice.

@mchades mchades force-pushed the pr-udf-client branch 2 times, most recently from e2af8e6 to ae87c94 Compare December 30, 2025 15:15
This PR implements the server-side REST API for User-Defined Functions (UDFs).

Changes include:
- Add FunctionDTO and related DTO classes for function metadata
- Add FunctionRegisterRequest and FunctionUpdateRequest for API requests
- Add FunctionResponse for API responses
- 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
This PR implements the storage layer for UDF (User-Defined Function)
persistence in the relational database backend.

Changes include:
- Add FunctionPO and FunctionVersionPO for database persistence
- Add FunctionMetaMapper and FunctionVersionMetaMapper for MyBatis
- Add FunctionMetaService for function metadata operations
- Add SQL schema scripts for MySQL, PostgreSQL, and H2 (v1.2.0)
- Add upgrade scripts from v1.1.0 to v1.2.0
- Update JDBCBackend to support FUNCTION entity type
- Add unit tests for FunctionMetaService
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Subtask] Java client support for UDF management

1 participant