Skip to content

Commit

Permalink
[#2376] fix(trino-connector) Gravitino-trino-connector is incompatibl…
Browse files Browse the repository at this point in the history
…e with Trino-435 (#2391)

### What changes were proposed in this pull request?

Remove the Trino runtime dependency to avoid version incompatibility.
Our Trino-connector uses Trino-426 for development. The
AllowAllAccessControl dependency, trino-toolkit-426.jar, causes
compatibility issues with Trino-426

### Why are the changes needed?
Fix: #2376

### Does this PR introduce _any_ user-facing change?

NO

### How was this patch tested?

Manually testing in Trino-435
  • Loading branch information
diqiu50 authored Mar 5, 2024
1 parent 638759b commit 169da0b
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 31 deletions.
37 changes: 19 additions & 18 deletions integration-test/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -268,27 +268,28 @@ tasks.test {
if (skipITs) {
exclude("**/integration/test/**")
} else {
// Get current project version
val version = project.version.toString()
println("Current project version: $version")
// Check whether this module has already built
val buildDir = project.buildDir
if (!buildDir.exists()) {
dependsOn(":trino-connector:jar")
} else {
// Check the version gravitino related jars in build equal to the current project version
val gravitinoJars = buildDir.resolve("libs").listFiles { _, name -> name.startsWith("gravitino") }?.filter {
val jarVersion = name.substringAfterLast("-").substringBeforeLast(".")
jarVersion != version
}
doFirst {
// Get current project version
val version = project.version.toString()
println("Current project version: $version")

// Check whether this module has already built
val trinoConnectorBuildDir = project(":trino-connector").buildDir
if (trinoConnectorBuildDir.exists()) {
// Check the version gravitino related jars in build equal to the current project version
val invalidGravitinoJars = trinoConnectorBuildDir.resolve("libs").listFiles { _, name -> name.startsWith("gravitino") }?.filter {
val name = it.name
!name.endsWith(version + ".jar")
}

if (gravitinoJars != null && gravitinoJars.isNotEmpty()) {
delete(project(":trino-connector").buildDir)
dependsOn(":trino-connector:jar")
if (invalidGravitinoJars!!.isNotEmpty()) {
val message = "Found mismatched versions of gravitino jars in trino-connector/build/libs:\n" +
"${invalidGravitinoJars.joinToString(", ") { it.name }}\n" +
"The current version of the project is $version. Please clean the project and rebuild it."
throw GradleException(message)
}
}
}

doFirst {
printDockerCheckInfo()

copy {
Expand Down
5 changes: 1 addition & 4 deletions trino-connector/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ dependencies {
implementation(libs.jackson.annotations)
implementation(libs.jackson.databind)
implementation(libs.commons.collections4)
implementation(libs.trino.spi) {
exclude("org.apache.logging.log4j")
}
implementation(libs.trino.toolkit) {
compileOnly(libs.trino.spi) {
exclude("org.apache.logging.log4j")
}
testImplementation(libs.mockito.core)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import com.datastrato.gravitino.trino.connector.catalog.CatalogConnectorContext;
import com.datastrato.gravitino.trino.connector.catalog.CatalogConnectorMetadata;
import com.google.common.base.Preconditions;
import io.trino.plugin.base.security.AllowAllAccessControl;
import io.trino.spi.connector.Connector;
import io.trino.spi.connector.ConnectorAccessControl;
import io.trino.spi.connector.ConnectorCapabilities;
Expand Down Expand Up @@ -134,7 +133,8 @@ public void commit(ConnectorTransactionHandle transactionHandle) {

@Override
public ConnectorAccessControl getAccessControl() {
return new AllowAllAccessControl();
Connector internalConnector = catalogConnectorContext.getInternalConnector();
return internalConnector.getAccessControl();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,8 @@ public ColumnMetadata getColumnMetadata(
}

GravitinoTableHandle gravitinoTableHandle = (GravitinoTableHandle) tableHandle;
GravitinoTable table =
catalogConnectorMetadata.getTable(
gravitinoTableHandle.getSchemaName(), gravitinoTableHandle.getTableName());

String columnName = getColumnName(session, gravitinoTableHandle, columnHandle);
GravitinoColumn column = table.getColumn(columnName);
return metadataAdapter.getColumnMetadata(column);
return internalMetadata.getColumnMetadata(
session, gravitinoTableHandle.getInternalTableHandle(), columnHandle);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public Map<String, Object> buildInternalConnectorConfig(GravitinoCatalog catalog

Map<String, Object> properties = new HashMap<>();
properties.put("hive.metastore.uri", catalog.getRequiredProperty("metastore.uris"));
properties.put("hive.security", "allow-all");
Map<String, String> trinoProperty =
catalogConverter.gravitinoToEngineProperties(catalog.getProperties());

Expand Down

0 comments on commit 169da0b

Please sign in to comment.