This is an automated email from the ASF dual-hosted git repository.
diqiu50 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gravitino.git
The following commit(s) were added to refs/heads/main by this push:
new 26068c1a55 feat: thrown a TrinoException if catalog-backend is missing
#1 (#8360)
26068c1a55 is described below
commit 26068c1a551d2662b26f41e9505fb8a7173993d6
Author: Daniele Carpentiero <[email protected]>
AuthorDate: Mon Sep 1 10:33:04 2025 +0200
feat: thrown a TrinoException if catalog-backend is missing #1 (#8360)
Title: [#8308] fix(iceberg): throw TrinoException when `catalog-backend`
is missing
### What changes were proposed in this pull request?
- Add an explicit check for a missing `catalog-backend` in
`gravitinoToEngineProperties(...)` and throw a `TrinoException` with
`GravitinoErrorCode.GRAVITINO_MISSING_REQUIRED_PROPERTY`.
- Keep existing backend property validators unchanged.
- No other functional changes.
### Why are the changes needed?
- Prevent a potential `NullPointerException` when switching on a `null`
backend.
- Align behavior with existing code paths and the review request.
Fixes: #8308
### Does this PR introduce any user-facing change?
- No breaking changes.
- Users now receive a clear error when the required `catalog-backend`
property is missing.
### How was this patch tested?
- Existing tests pass.
- Manual verification of error message and code.
Files touched:
-
`trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/catalog/iceberg/IcebergCatalogPropertyConverter.java`
---
.../connector/catalog/iceberg/IcebergCatalogPropertyConverter.java | 4 ++++
1 file changed, 4 insertions(+)
diff --git
a/trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/catalog/iceberg/IcebergCatalogPropertyConverter.java
b/trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/catalog/iceberg/IcebergCatalogPropertyConverter.java
index 06d45aa84b..02f43c88dd 100644
---
a/trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/catalog/iceberg/IcebergCatalogPropertyConverter.java
+++
b/trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/catalog/iceberg/IcebergCatalogPropertyConverter.java
@@ -47,6 +47,10 @@ public class IcebergCatalogPropertyConverter extends
CatalogPropertyConverter {
public Map<String, String> gravitinoToEngineProperties(Map<String, String>
properties) {
Map<String, String> stringStringMap;
String backend = properties.get("catalog-backend");
+ if (backend == null)
+ throw new TrinoException(
+ GravitinoErrorCode.GRAVITINO_MISSING_REQUIRED_PROPERTY,
+ "Missing required property 'catalog-backend'");
switch (backend) {
case "hive":
stringStringMap = buildHiveBackendProperties(properties);