This is an automated email from the ASF dual-hosted git repository.
yuqi4733 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 8c4a32590 [#3785] Throw a clear exception for unsupported Trino
versions when Trino starts (#4268)
8c4a32590 is described below
commit 8c4a325907f353c33a5a1a25c3f460642ea116cf
Author: Yuhui <[email protected]>
AuthorDate: Mon Jul 29 20:55:18 2024 +0800
[#3785] Throw a clear exception for unsupported Trino versions when Trino
starts (#4268)
### What changes were proposed in this pull request?
Throw a clear exception for unsupported Trino versions when Trino starts
Currently, we know the supported version is between Trino-435 and
Trino-439.
Remove configuration of `gravitino.simplify-catalog-names` from docs,
it's not support in current version
### Why are the changes needed?
Fix: #3785
### Does this PR introduce _any_ user-facing change?
Yes
### How was this patch tested?
Manually test
---
docs/trino-connector/configuration.md | 1 -
docs/trino-connector/installation.md | 2 --
docs/trino-connector/requirements.md | 2 +-
.../trino/connector/catalog/CatalogRegister.java | 25 ++++++++++++++++++----
4 files changed, 22 insertions(+), 8 deletions(-)
diff --git a/docs/trino-connector/configuration.md
b/docs/trino-connector/configuration.md
index 8e066caac..25d5d4871 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 f7fc1b75f..0b4f0db6d 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 becc09c33..903d2f9df 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 14bc8243d..1749d8aa3 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);