Skip to content

[#12927] fix(function): Reject unresolved data types in new definitions - #12928

Open
mchades wants to merge 2 commits into
mainfrom
codex/strict-function-data-type-input
Open

[#12927] fix(function): Reject unresolved data types in new definitions#12928
mchades wants to merge 2 commits into
mainfrom
codex/strict-function-data-type-input

Conversation

@mchades

@mchades mchades commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

  • Validate parameter, scalar return, and table return-column types when registering or adding a function definition.
  • Accept native Gravitino types and explicit, non-blank ExternalType values.
  • Reject UnparsedType recursively with indexed field paths and HTTP 400 responses.
  • Add a WritableDataType OpenAPI schema for function write requests.
  • Preserve the shared read deserializer and legacy selector behavior.

Why are the changes needed?

Unknown strings and malformed type objects currently deserialize as UnparsedType and can be persisted as new function metadata because request validation only checks for null.

Part of #12927.

Does this PR introduce any user-facing change?

Yes. Function register and AddDefinition now reject unknown, malformed, or explicit UnparsedType inputs with HTTP 400. Existing function responses and selector-based management operations remain backward compatible. Table APIs are unchanged.

How was this patch tested?

  • Focused common request and DTO tests
  • TestFunctionPO
  • TestManagedFunctionOperations
  • Focused TestFunctionOperations REST tests
  • ./gradlew spotlessApply
  • ./gradlew :docs:build
  • git diff --check

Copilot AI lite review requested due to automatic review settings September 4, 2026 10:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The change is well-scoped, aligns with the stated contract split (read vs write), and is backed by targeted DTO/REST/core tests with only a minor error-message wording nit.

Pull request overview

This PR tightens function-metadata write validation so new function definitions can no longer persist unresolved UnparsedType (while preserving backward-compatible read behavior for legacy metadata). It also updates the OpenAPI contract to distinguish read-compatible DataType from write-only WritableDataType.

Changes:

  • Add DTO-level validation that rejects UnparsedType (recursively) and requires non-blank ExternalType.catalogString for function register/addDefinition requests.
  • Extend REST and managed-metadata tests to cover legacy readability, selector compatibility, and 400 responses for invalid write inputs.
  • Update OpenAPI schemas to introduce WritableDataType / writable function-definition shapes for write requests.
File summaries
File Description
server/src/test/java/org/apache/gravitino/server/web/rest/TestFunctionOperations.java Adds REST tests for legacy read compatibility and 400 rejection of unparsed types on writes.
docs/open-api/functions.yaml Updates function write request schemas to use writable function-definition types; documents 400 responses and legacy read behavior.
docs/open-api/datatype.yaml Introduces WritableDataType and writable type variants excluding UnparsedType.
core/src/test/java/org/apache/gravitino/storage/relational/po/TestFunctionPO.java Verifies legacy persisted type strings deserialize as UnparsedType and remain readable.
core/src/test/java/org/apache/gravitino/catalog/TestManagedFunctionOperations.java Ensures selector-based management operations still work with legacy UnparsedType definitions.
common/src/test/java/org/apache/gravitino/dto/requests/TestFunctionUpdatesRequest.java Validates indexed update-paths appear in addDefinition validation errors; confirms selectors allow legacy unparsed types.
common/src/test/java/org/apache/gravitino/dto/requests/TestFunctionUpdateRequest.java Adds coverage for addDefinition rejecting UnparsedType and allowing selector requests with legacy types.
common/src/test/java/org/apache/gravitino/dto/requests/TestFunctionRegisterRequest.java Adds coverage for rejecting unknown/unparsed/nested-unparsed types with field-paths; validates ExternalType acceptance.
common/src/test/java/org/apache/gravitino/dto/function/TestFunctionDTO.java Confirms function DTO reads still accept legacy unresolved types (UnparsedType).
common/src/main/java/org/apache/gravitino/dto/requests/FunctionUpdatesRequest.java Adjusts validation to include update-indexed field paths for addDefinition validation.
common/src/main/java/org/apache/gravitino/dto/requests/FunctionUpdateRequest.java Routes addDefinition validation through the shared data-type validator with field-path support.
common/src/main/java/org/apache/gravitino/dto/requests/FunctionRegisterRequest.java Adds per-definition field-paths and calls shared data-type validation for register requests.
common/src/main/java/org/apache/gravitino/dto/requests/FunctionDataTypeValidator.java New shared validator that rejects UnparsedType on writes and validates nested/native/external types.
Review details
  • Files reviewed: 13/13 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown

Code Coverage Report

Overall Project 69.52% +0.02% 🟢
Files changed 81.93% 🟢

Module Coverage
aliyun 19.74% 🔴
api 51.57% 🟢
authorization-common 85.96% 🟢
authorization-ranger 4.38% 🔴
aws 53.54% 🟢
azure 32.1% 🔴
catalog-common 20.87% 🔴
catalog-fileset 82.17% 🟢
catalog-glue 69.24% 🟢
catalog-hive 82.96% 🟢
catalog-jdbc-common 45.69% 🟢
catalog-jdbc-doris 82.69% 🟢
catalog-jdbc-mysql 79.33% 🟢
catalog-jdbc-postgresql 83.39% 🟢
catalog-jdbc-starrocks 79.16% 🟢
catalog-kafka 76.99% 🟢
catalog-lakehouse-generic 60.88% 🟢
catalog-lakehouse-hudi 79.1% 🟢
catalog-lakehouse-iceberg 85.97% 🟢
catalog-lakehouse-paimon 84.29% 🟢
catalog-model 77.99% 🟢
cli 44.51% 🟢
client-java 77.5% 🟢
common 56.89% +0.57% 🟢
core 83.97% 🟢
filesystem-hadoop3 76.48% 🟢
flink 0.0% 🔴
flink-common 52.1% 🟢
flink-runtime 0.0% 🔴
gcp 32.2% 🔴
hadoop-auth 68.0% 🟢
hadoop-common 17.84% 🔴
hive-metastore-common 53.4% 🟢
iceberg-aliyun-bundle 0.0% 🔴
iceberg-common 66.58% 🟢
iceberg-rest-server 76.61% 🟢
idp-basic 87.1% 🟢
integration-test-common 0.0% 🔴
jobs 62.92% 🟢
lance-common 32.52% 🔴
lance-rest-server 68.02% 🟢
lineage 59.39% 🟢
optimizer 83.24% 🟢
optimizer-api 21.95% 🔴
server 90.08% 🟢
server-common 81.27% 🟢
spark 28.57% 🔴
spark-common 52.04% 🟢
tencent 81.78% 🟢
trino-connector 58.36% 🟢
Files
Module File Coverage
common FunctionRegisterRequest.java 92.31% 🟢
FunctionUpdateRequest.java 89.74% 🟢
FunctionUpdatesRequest.java 81.25% 🟢
FunctionDataTypeValidator.java 63.04% 🟢

@mchades
mchades requested a review from jerryshao September 4, 2026 15:03
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.

2 participants