Skip to content

World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.

[#3785] Throw a clear exception for unsupported Trino versions when Trino starts (#4268)

Yuhui8c4a325907f3
diff --git a/docs/trino-connector/configuration.md b/docs/trino-connector/configuration.md
index 8e066caac5..25d5d48712 100644
--- a/docs/trino-connector/configuration.md
+++ b/docs/trino-connector/configuration.md
@@ -10,6 +10,5 @@ license: "This software is licensed under the Apache License version 2."
| connector.name | string | (none) | The `connector.name` defines the type of Trino connector, this value is always 'gravitino'. | Yes | 0.2.0 |
| gravitino.metalake | string | (none) | The `gravitino.metalake` defines which metalake in Gravitino server the Trino connector uses. Trino connector should set it at start, the value of `gravitino.metalake` needs to be a valid name, Trino connector can detect and load the metalake with catalogs, schemas and tables once created and keep in sync. | Yes | 0.2.0 |
| gravitino.uri | string | http://localhost:8090 | The `gravitino.uri` defines the connection URL of the Gravitino server, the default value is `http://localhost:8090`. Trino connector can detect and connect to Gravitino server once it is ready, no need to start Gravitino server beforehand. | No | 0.2.0 |
-| gravitino.simplify-catalog-names | boolean | true | The `gravitino.simplify-catalog-names` setting omits the metalake prefix from catalog names when set to true. | NO | 0.5.0 |
| trino.jdbc.user | string | admin | The jdbc user name of current Trino. | NO | 0.5.1 |
| trino.jdbc.password | string | (none) | The jdbc password of current Trino. | NO | 0.5.1 |
diff --git a/docs/trino-connector/installation.md b/docs/trino-connector/installation.md
index f7fc1b75f1..0b4f0db6df 100644
--- a/docs/trino-connector/installation.md
+++ b/docs/trino-connector/installation.md
@@ -96,13 +96,11 @@ To configure Gravitino connector correctly, you need to put the following config
connector.name=gravitino
gravitino.uri=http://gravitino-server-host:8090
gravitino.metalake=test
-gravitino.simplify-catalog-names=true
```
- The `gravitino.name` defines which Gravitino connector is used. It must be `gravitino`.
- The `gravitino.metalake` defines which metalake are used. It should exist in the Gravitino server.
- The `gravitino.uri` defines the connection information about Gravitino server. Make sure your container can access the Gravitino server.
-- The `gravitino.simplify-catalog-names` setting omits the metalake prefix from catalog names when set to true.
Full configurations for Apache Gravitino connector can be seen [here](configuration.md)
diff --git a/docs/trino-connector/requirements.md b/docs/trino-connector/requirements.md
index becc09c335..903d2f9df1 100644
--- a/docs/trino-connector/requirements.md
+++ b/docs/trino-connector/requirements.md
@@ -7,7 +7,7 @@ license: "This software is licensed under the Apache License version 2."
To install and deploy the Apache Gravitino connector, The following environmental setup is necessary:
-- Trino server version should be at least Trino-server-435.
+- Trino server version should be between Trino-server-435 and Trino-server-439.
Other versions of Trino have not undergone thorough testing.
- Ensure that all nodes running Trino can access the Gravitino server's port, which defaults to 8090.
- Ensure that all nodes running Trino can access the real catalogs resources, such as Hive, Iceberg, MySQL, PostgreSQL, etc.
diff --git a/trino-connector/src/main/java/org/apache/gravitino/trino/connector/catalog/CatalogRegister.java b/trino-connector/src/main/java/org/apache/gravitino/trino/connector/catalog/CatalogRegister.java
index 14bc8243de..1749d8aa32 100644
--- a/trino-connector/src/main/java/org/apache/gravitino/trino/connector/catalog/CatalogRegister.java
+++ b/trino-connector/src/main/java/org/apache/gravitino/trino/connector/catalog/CatalogRegister.java
@@ -47,7 +47,9 @@ public class CatalogRegister {
private static final Logger LOG = LoggerFactory.getLogger(CatalogRegister.class);
- private static final int MIN_TRINO_SPI_VERSION = 435;
+ private static final int MIN_SUPPORT_TRINO_SPI_VERSION = 435;
+ private static final int MAX_SUPPORT_TRINO_SPI_VERSION = 439;
+ private static final int MIN_SUPPORT_CATALOG_NAME_WITH_METALAKE_TRINO_SPI_VERSION = 446;
private static final int EXECUTE_QUERY_MAX_RETRIES = 6;
private static final int EXECUTE_QUERY_BACKOFF_TIME_SECOND = 5;
@@ -62,17 +64,31 @@ public class CatalogRegister {
this.trinoVersion = context.getSpiVersion();
int version = Integer.parseInt(context.getSpiVersion());
- if (version < MIN_TRINO_SPI_VERSION) {
+ if (version < MIN_SUPPORT_TRINO_SPI_VERSION || version > MAX_SUPPORT_TRINO_SPI_VERSION) {
String errmsg =
String.format(
- "Unsupported Trino-%s version. min support version is Trino-%d",
- trinoVersion, MIN_TRINO_SPI_VERSION);
+ "Unsupported Trino-%s version. The Supported version for the Gravitino-Trino-connector from Trino-%d to Trino-%d",
+ trinoVersion, MIN_SUPPORT_TRINO_SPI_VERSION, MAX_SUPPORT_TRINO_SPI_VERSION);
throw new TrinoException(GravitinoErrorCode.GRAVITINO_UNSUPPORTED_TRINO_VERSION, errmsg);
}
isCoordinator = context.getNodeManager().getCurrentNode().isCoordinator();
}
+ private void checkSupportCatalogNameWithMetalake(
+ ConnectorContext context, GravitinoConfig config) {
+ if (!config.simplifyCatalogNames()) {
+ int version = Integer.parseInt(context.getSpiVersion());
+ if (version < MIN_SUPPORT_CATALOG_NAME_WITH_METALAKE_TRINO_SPI_VERSION) {
+ String errmsg =
+ String.format(
+ "Trino-%s does not support catalog name with dots, The minimal required version is Trino-%d",
+ trinoVersion, MIN_SUPPORT_CATALOG_NAME_WITH_METALAKE_TRINO_SPI_VERSION);
+ throw new TrinoException(GravitinoErrorCode.GRAVITINO_UNSUPPORTED_TRINO_VERSION, errmsg);
+ }
+ }
+ }
+
boolean isCoordinator() {
return isCoordinator;
}
@@ -95,6 +111,7 @@ public class CatalogRegister {
public void init(ConnectorContext context, GravitinoConfig config) throws Exception {
this.config = config;
checkTrinoSpiVersion(context);
+ checkSupportCatalogNameWithMetalake(context, config);
TrinoDriver driver = new TrinoDriver();
DriverManager.registerDriver(driver);