Skip to content

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

[#699] feat(trino-connector) Support Iceberg catalogs in trino-connector (#858)

Yuhui57abc3d2c108
diff --git a/build.gradle.kts b/build.gradle.kts
index bbd1e9a733..6da5381020 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -151,6 +151,7 @@ subprojects {
if (!skipTests) {
if (project.name == "trino-connector") {
useTestNG()
+ maxHeapSize = "2G"
} else {
useJUnitPlatform()
}
@@ -225,12 +226,14 @@ tasks.rat {
"dev/docker/**/*.xml",
"**/*.log",
"licenses/*txt",
+ "integration-test/**",
"web/.**",
- "web/node_modules/**/*",
"web/dist/**/*",
+ "web/node_modules/**/*",
"web/src/iconify-bundle/bundle-icons-react.js",
"web/src/iconify-bundle/icons-bundle-react.js",
"web/yarn.lock",
+ "integration-test/**"
)
// Add .gitignore excludes to the Apache Rat exclusion list.
diff --git a/docs/trino-gravitino-connector.md b/docs/trino-gravitino-connector.md
index ede8385023..e2b43668bb 100644
--- a/docs/trino-gravitino-connector.md
+++ b/docs/trino-gravitino-connector.md
@@ -30,7 +30,7 @@ Please refer to the [Deploying Trino documentation](https://trino.io/docs/curren
1. Download Gravitino connector tarball and unpack it.
The tarball contains a single top-level directory `gravitino-trino-connector-xxx`,
which we call the connector directory.
- [Download the graviton-connector](https://github.com/datastrato/gravitino/releases).
+ [Download the gravitino-connector](https://github.com/datastrato/gravitino/releases).
2. Copy the connector directory to trino plugin's directory.
Normally, the directory location is `Trino-server-xxx/plugin`, and the directory contains other catalogs used by Trino.
3. Add trino jvm arguments `-Dlog4j.configurationFile=file:///xxx/log4j2.properties` to enable logging for the Gravitino connector.
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index ca6ce50f76..2ac499b614 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -34,6 +34,8 @@ testng = "7.5.1"
testcontainers = "1.19.0"
trino-jdbc = "426"
jwt = "0.11.1"
+jline = "3.21.0"
+okhttp3 = "4.11.0"
protobuf-plugin = "0.9.2"
spotless-plugin = '6.11.0'
@@ -98,6 +100,8 @@ trino-spi= { group = "io.trino", name = "trino-spi", version.ref = "trino" }
trino-toolkit= { group = "io.trino", name = "trino-plugin-toolkit", version.ref = "trino" }
trino-testing= { group = "io.trino", name = "trino-testing", version.ref = "trino" }
trino-memory= { group = "io.trino", name = "trino-memory", version.ref = "trino" }
+trino-cli= { group = "io.trino", name = "trino-cli", version.ref = "trino" }
+trino-client= { group = "io.trino", name = "trino-client", version.ref = "trino" }
iceberg-spark-runtime = { group = "org.apache.iceberg", name = "iceberg-spark-runtime-3.4_2.13", version.ref = "iceberg" }
spark-sql = { group = "org.apache.spark", name = "spark-sql_2.13", version.ref = "spark" }
scala-collection-compat = { group = "org.scala-lang.modules", name = "scala-collection-compat_2.13", version.ref = "scala-collection-compat" }
@@ -116,6 +120,8 @@ metrics-core = { group = "io.dropwizard.metrics", name = "metrics-core", version
metrics-jersey2 = { group = "io.dropwizard.metrics", name = "metrics-jersey2", version.ref = "metrics" }
metrics-jvm = { group = "io.dropwizard.metrics", name = "metrics-jvm", version.ref = "metrics" }
metrics-jmx = { group = "io.dropwizard.metrics", name = "metrics-jmx", version.ref = "metrics" }
+jline-terminal = { group = "org.jline", name = "jline-terminal", version.ref = "jline" }
+okhttp3-loginterceptor = { group = "com.squareup.okhttp3", name = "logging-interceptor", version.ref = "okhttp3" }
metrics-servlets = { group = "io.dropwizard.metrics", name = "metrics-servlets", version.ref = "metrics" }
prometheus-client = { group = "io.prometheus", name = "simpleclient", version.ref = "prometheus" }
prometheus-dropwizard = { group = "io.prometheus", name = "simpleclient_dropwizard", version.ref = "prometheus" }
diff --git a/integration-test/build.gradle.kts b/integration-test/build.gradle.kts
index 6eb07a9619..a67fcc5e3a 100644
--- a/integration-test/build.gradle.kts
+++ b/integration-test/build.gradle.kts
@@ -111,6 +111,12 @@ dependencies {
testImplementation(libs.testcontainers.junit.jupiter)
testImplementation(libs.testcontainers.mysql)
testImplementation(libs.trino.jdbc)
+ testImplementation(libs.trino.cli)
+ testImplementation(libs.trino.client) {
+ exclude("jakarta.annotation")
+ }
+ testImplementation(libs.jline.terminal)
+ testImplementation(libs.okhttp3.loginterceptor)
testImplementation(libs.mysql.driver)
}
diff --git a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/trino/TrinoQueryIT.java b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/trino/TrinoQueryIT.java
new file mode 100644
index 0000000000..7b6c756302
--- /dev/null
+++ b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/trino/TrinoQueryIT.java
@@ -0,0 +1,448 @@
+/*
+ * Copyright 2023 Datastrato.
+ * This software is licensed under the Apache License version 2.
+ */
+package com.datastrato.gravitino.integration.test.trino;
+
+import static io.trino.cli.ClientOptions.OutputFormat.CSV;
+import static java.lang.Thread.sleep;
+
+import com.datastrato.gravitino.Catalog;
+import com.datastrato.gravitino.NameIdentifier;
+import com.datastrato.gravitino.Namespace;
+import com.datastrato.gravitino.client.GravitinoClient;
+import com.datastrato.gravitino.client.GravitinoMetaLake;
+import com.datastrato.gravitino.rel.SupportsSchemas;
+import com.datastrato.gravitino.rel.TableCatalog;
+import io.trino.cli.Query;
+import io.trino.cli.QueryRunner;
+import io.trino.cli.TerminalUtils;
+import io.trino.client.ClientSession;
+import io.trino.client.uri.TrinoUri;
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.net.URI;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.time.ZoneId;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.concurrent.CompletionService;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorCompletionService;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import jodd.io.StringOutputStream;
+import okhttp3.logging.HttpLoggingInterceptor;
+import org.jline.terminal.Terminal;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.mortbay.log.Log;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@Tag("gravitino-docker-it")
+public class TrinoQueryIT {
+ private static final Logger LOG = LoggerFactory.getLogger(TrinoQueryIT.class);
+
+ private static boolean isDockerRunning = false;
+
+ // TODO(yuhui) redo get the configs after we have the Docker image ready for testing.
+ private static String gravitinoUri = "http://127.0.0.1:8090";
+ private static String trinoUri = "http://127.0.0.1:8080";
+ private static String hiveMetastoreUri = "thrift://127.0.0.1:9083";
+
+ private static final String metalakeName = "test";
+
+ private static GravitinoClient client;
+ private static GravitinoMetaLake metalake;
+ private static String testQueriesDir = "";
+ private static AtomicInteger testCount = new AtomicInteger(0);
+ private static AtomicInteger totalCount = new AtomicInteger(0);
+ static TrinoQueryRunner trinoQueryRunner;
+ private static String targetCatalog = null;
+
+ @BeforeAll
+ public static void setup() throws Exception {
+
+ try {
+ client = GravitinoClient.builder(gravitinoUri).build();
+ trinoQueryRunner = new TrinoQueryRunner();
+
+ createMetalake();
+
+ if (targetCatalog == null || targetCatalog.equals("hive")) {
+ dropCatalog("hive");
+ HashMap<String, String> properties = new HashMap<>();
+ properties.put("metastore.uris", hiveMetastoreUri);
+
+ createCatalog("hive", "hive", properties);
+ }
+
+ if (targetCatalog == null || targetCatalog.equals("lakehouse-iceberg")) {
+ dropCatalog("lakehouse-iceberg");
+ HashMap<String, String> properties = new HashMap<>();
+ properties.put("uri", hiveMetastoreUri);
+ properties.put("catalog-backend", "hive");
+ properties.put("warehouse", "hdfs://localhost:9000/user/iceberg/warehouse/TrinoQueryIT");
+ createCatalog("lakehouse-iceberg", "lakehouse-iceberg", properties);
+ }
+
+ isDockerRunning = true;
+ } catch (Exception e) {
+ LOG.error("Services are not connected", e);
+ return;
+ }
+
+ testQueriesDir =
+ TrinoQueryIT.class.getClassLoader().getResource("trino-queries/catalogs").getPath();
+ LOG.info("Test Queries directory is {}", testQueriesDir);
+ }
+
+ @AfterAll
+ public static void cleanup() {
+ trinoQueryRunner.stop();
+ }
+
+ private static void createMetalake() {
+ boolean exists = client.metalakeExists(NameIdentifier.of(metalakeName));
+ if (exists) {
+ metalake = client.loadMetalake(NameIdentifier.of(metalakeName));
+ return;
+ }
+
+ GravitinoMetaLake createdMetalake =
+ client.createMetalake(NameIdentifier.of(metalakeName), "comment", Collections.emptyMap());
+ Assertions.assertNotNull(createdMetalake);
+ metalake = createdMetalake;
+ }
+
+ private static void dropMetalake() {
+ boolean exists = client.metalakeExists(NameIdentifier.of(metalakeName));
+ if (!exists) {
+ return;
+ }
+ client.dropMetalake(NameIdentifier.of(metalakeName));
+ }
+
+ private static void createCatalog(
+ String catalogName, String provider, Map<String, String> properties)
+ throws InterruptedException {
+ boolean exists = metalake.catalogExists(NameIdentifier.of(metalakeName, catalogName));
+ if (!exists) {
+ Catalog createdCatalog =
+ metalake.createCatalog(
+ NameIdentifier.of(metalakeName, catalogName),
+ Catalog.Type.RELATIONAL,
+ provider,
+ "comment",
+ properties);
+ Assertions.assertNotNull(createdCatalog);
+ }
+
+ boolean catalogCreated = false;
+ int tries = 30;
+ while (!catalogCreated && tries-- >= 0) {
+ String result = trinoQueryRunner.runQuery("show catalogs");
+ if (result.contains(metalakeName + "." + catalogName)) {
+ catalogCreated = true;
+ break;
+ }
+ sleep(1000);
+ LOG.info("Waiting for catalog {} to be created", catalogName);
+ }
+
+ if (!catalogCreated) {
+ Assertions.fail("Catalog " + catalogName + " not created");
+ }
+ }
+
+ private static void dropCatalog(String catalogName) {
+ boolean exists = metalake.catalogExists(NameIdentifier.of(metalakeName, catalogName));
+ if (!exists) {
+ return;
+ }
+ Catalog catalog = metalake.loadCatalog(NameIdentifier.of(metalakeName, catalogName));
+ SupportsSchemas schemas = catalog.asSchemas();
+ Arrays.stream(schemas.listSchemas(Namespace.ofSchema(metalakeName, catalogName)))
+ .filter(schema -> !schema.name().equals("default"))
+ .forEach(
+ schema -> {
+ try {
+ TableCatalog tableCatalog = catalog.asTableCatalog();
+ Arrays.stream(
+ tableCatalog.listTables(
+ Namespace.ofTable(metalakeName, catalogName, schema.name())))
+ .forEach(
+ table -> {
+ try {
+ tableCatalog.purgeTable(
+ NameIdentifier.ofTable(
+ metalakeName, catalogName, schema.name(), table.name()));
+ } catch (UnsupportedOperationException e) {
+ tableCatalog.dropTable(
+ NameIdentifier.ofTable(
+ metalakeName, catalogName, schema.name(), table.name()));
+ LOG.info(
+ "Drop table \"{}.{}\".{}.{}",
+ metalakeName,
+ catalogName,
+ schema.name(),
+ table.name());
+ } catch (Exception e) {
+ LOG.error("Failed to drop table {}", table);
+ }
+ });
+
+ schemas.dropSchema(
+ NameIdentifier.ofSchema(metalakeName, catalogName, schema.name()), true);
+ } catch (Exception e) {
+ LOG.error("Failed to drop schema {}", schema);
+ }
+ LOG.info("Drop schema \"{}.{}\".{}", metalakeName, catalogName, schema.name());
+ });
+
+ metalake.dropCatalog(NameIdentifier.of(metalakeName, catalogName));
+ LOG.info("Drop catalog \"{}.{}\"", metalakeName, catalogName);
+ }
+
+ private String[] readCatalogNames() throws Exception {
+ File dir = new File(testQueriesDir);
+ if (dir.exists()) {
+ return dir.list();
+ }
+ throw new Exception("Test queries directory does not exist");
+ }
+
+ @Test
+ public void testSql() throws Exception {
+ if (!isDockerRunning) {
+ return;
+ }
+
+ String[] catalogNames = readCatalogNames();
+
+ ExecutorService executor = Executors.newFixedThreadPool(catalogNames.length);
+ CompletionService completionService = new ExecutorCompletionService<>(executor);
+
+ List<Future<Integer>> futures = new ArrayList<>();
+ for (int i = 0; i < catalogNames.length; i++) {
+ int finalI = i;
+ futures.add(
+ completionService.submit(
+ () -> {
+ try {
+ runQueriesAndCheck(catalogNames[finalI], null);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ LOG.debug("Catalog {} test run completed", catalogNames[finalI]);
+ return finalI;
+ }));
+ }
+ for (int i = 0; i < catalogNames.length; i++) {
+ try {
+ Future<Integer> completedTask = completionService.take();
+ Integer taskId = completedTask.get();
+ } catch (InterruptedException | ExecutionException e) {
+ LOG.error("Test failed: ", e);
+ Assertions.fail("Test failed: " + e.getMessage());
+ }
+ }
+
+ Log.info("All tests completed");
+ executor.shutdownNow();
+ executor.awaitTermination(3, TimeUnit.SECONDS);
+ }
+
+ private String[] loadAllTestFiles(String dirName, String filterPrefix) {
+ String targetDir = testQueriesDir + "/" + dirName;
+ File targetDirFile = new File(targetDir);
+ if (!targetDirFile.exists()) {
+ return new String[0];
+ }
+
+ String[] files =
+ Arrays.stream(targetDirFile.list())
+ .filter(name -> filterPrefix == null || name.startsWith(filterPrefix))
+ .toArray(String[]::new);
+
+ totalCount.addAndGet(files.length / 2);
+ return files;
+ }
+
+ private String readFileToString(String filename) throws IOException {
+ return new String(Files.readAllBytes(Paths.get(filename))) + "\n\n";
+ }
+
+ private void runQueriesAndCheck(String testDirName, String testerId) throws Exception {
+ String[] testFileNames = loadAllTestFiles(testDirName, testerId);
+
+ TrinoQueryRunner queryRunner = new TrinoQueryRunner();
+
+ Arrays.sort(testFileNames);
+ for (int i = 0; i < testFileNames.length; i += 2) {
+ String fileNamePrefix = testFileNames[i].substring(0, testFileNames[i].lastIndexOf('.'));
+ fileNamePrefix = testQueriesDir + "/" + testDirName + "/" + fileNamePrefix;
+ String testFileName = fileNamePrefix + ".sql";
+ String testResultFileName = fileNamePrefix + ".txt";
+
+ String testSql = readFileToString(testFileName);
+ String testResult = readFileToString(testResultFileName);
+
+ Matcher sqlMatcher =
+ Pattern.compile("(\\w.*?);", Pattern.DOTALL | Pattern.UNIX_LINES).matcher(testSql);
+ Matcher resultMatcher =
+ Pattern.compile("(\\S.*?)\\n{2,}", Pattern.DOTALL | Pattern.UNIX_LINES)
+ .matcher(testResult);
+
+ while (sqlMatcher.find()) {
+ String sql = sqlMatcher.group(1);
+ String expectResult = "";
+ if (resultMatcher.find()) {
+ expectResult = resultMatcher.group(1) + "\n";
+ }
+
+ String result = queryRunner.runQuery(sql);
+
+ boolean match;
+
+ if (Pattern.compile("^Query \\w+ failed:").matcher(result).find()) {
+ match =
+ Pattern.compile("^Query \\w+ failed.*: " + expectResult.trim())
+ .matcher(result)
+ .find();
+ } else {
+ match = expectResult.trim().equals(result.trim());
+ }
+
+ if (match) {
+ LOG.info(
+ "Test {} success.\nSql:\n{};\nExpect:\n{}\nActual:\n{}",
+ testDirName + testFileName.substring(testFileName.lastIndexOf('/')),
+ sql,
+ expectResult,
+ result);
+ } else {
+ queryRunner.stop();
+ String errorMessage =
+ String.format(
+ "Test %s failed for query.\nSql:\n%s\nExpect:\n%s\nActual:\n%s",
+ testDirName + testFileName.substring(testFileName.lastIndexOf('/')),
+ sql,
+ expectResult,
+ result);
+ LOG.error(errorMessage);
+ Assertions.fail(errorMessage);
+ }
+ }
+ testCount.incrementAndGet();
+ LOG.info(
+ "Test {} success. progress {}/{}",
+ testDirName + testFileName.substring(testFileName.lastIndexOf('/')),
+ testCount.get(),
+ totalCount.get());
+ }
+ queryRunner.stop();
+ }
+
+ static class TrinoQueryRunner {
+ private QueryRunner queryRunner;
+ private Terminal terminal;
+ private URI uri = new URI("http://192.168.215.2:8080");
+
+ TrinoQueryRunner() throws Exception {
+ this.uri = new URI(trinoUri);
+ this.queryRunner = createQueryRunner();
+ this.terminal = TerminalUtils.getTerminal();
+ }
+
+ private QueryRunner createQueryRunner() throws Exception {
+
+ TrinoUri trinoUri = TrinoUri.builder().setUri(uri).build();
+
+ ClientSession session =
+ ClientSession.builder()
+ .server(uri)
+ .user(Optional.of("admin"))
+ .timeZone(ZoneId.systemDefault())
+ .build();
+ return new QueryRunner(trinoUri, session, false, HttpLoggingInterceptor.Level.NONE);
+ }
+
+ String runQuery(String query) {
+ Query queryResult = queryRunner.startQuery(query);
+ StringOutputStream outputStream = new StringOutputStream();
+ queryResult.renderOutput(
+ this.terminal,
+ new PrintStream(outputStream),
+ new PrintStream(outputStream),
+ CSV,
+ Optional.of(""),
+ false);
+ return outputStream.toString();
+ }
+
+ boolean stop() {
+ try {
+ queryRunner.close();
+ terminal.close();
+ return true;
+ } catch (Exception e) {
+ LOG.error("Failed to stop query runner", e);
+ return false;
+ }
+ }
+ }
+
+ public static void main(String[] args) {
+ String targetTestId = null;
+ try {
+
+ if (args.length == 1) {
+ // e.g.: args = hive
+ // run hive all the test cases
+ targetCatalog = args[0];
+ setup();
+ TrinoQueryIT testRunner = new TrinoQueryIT();
+ testRunner.runQueriesAndCheck(targetCatalog, targetTestId);
+
+ } else if (args.length == 2) {
+ // e.g: args = hive 00001
+ // run hive test case 00001
+ targetCatalog = args[0];
+ targetTestId = args[1];
+
+ setup();
+ TrinoQueryIT testRunner = new TrinoQueryIT();
+ testRunner.runQueriesAndCheck(targetCatalog, targetTestId);
+ } else if (args.length == 0) {
+ // e.g.: empty args
+ // run all catalogs all the test cases
+ setup();
+ TrinoQueryIT testRunner = new TrinoQueryIT();
+ testRunner.testSql();
+ }
+
+ } catch (Exception e) {
+ LOG.error("", e);
+ } finally {
+ cleanup();
+ System.exit(0);
+ }
+ }
+}
diff --git a/integration-test/src/test/resources/trino-queries/bugs/00001_alter_table.sql b/integration-test/src/test/resources/trino-queries/bugs/00001_alter_table.sql
new file mode 100644
index 0000000000..13af3e576b
--- /dev/null
+++ b/integration-test/src/test/resources/trino-queries/bugs/00001_alter_table.sql
@@ -0,0 +1,13 @@
+CREATE SCHEMA "test.hive".db1;
+
+CREATE TABLE "test.hive".db1.tb01 (
+ name varchar,
+ salary int
+)
+WITH (
+ format = 'TEXTFILE'
+);
+
+alter table "test.hive".db1.tb01 add column city varchar comment 'aaa';
+
+show create table "test.hive".db1.tb01;
\ No newline at end of file
diff --git a/integration-test/src/test/resources/trino-queries/bugs/00002_drop_table.sql b/integration-test/src/test/resources/trino-queries/bugs/00002_drop_table.sql
new file mode 100644
index 0000000000..8a510cb41e
--- /dev/null
+++ b/integration-test/src/test/resources/trino-queries/bugs/00002_drop_table.sql
@@ -0,0 +1,31 @@
+CREATE SCHEMA "test.hive".db1;
+
+CREATE TABLE "test.hive".db1.tb01 (
+ name varchar,
+ salary int
+)
+WITH (
+ format = 'TEXTFILE'
+);
+
+insert into "test.hive".db1.tb01(name, salary) values ('sam', 11);
+insert into "test.hive".db1.tb01(name, salary) values ('jerry', 13);
+
+select * from "test.hive".db1.tb01 order by name;
+
+drop table "test.hive".db1.tb01;
+drop schema "test.hive".db1;
+
+CREATE SCHEMA "test.hive".db1;
+
+CREATE TABLE "test.hive".db1.tb01 (
+ name varchar,
+ salary int
+)
+WITH (
+ format = 'TEXTFILE'
+);
+
+select * from "test.hive".db1.tb01 order by name;
+
+
diff --git a/integration-test/src/test/resources/trino-queries/catalogs/hive/00000_create_table.sql b/integration-test/src/test/resources/trino-queries/catalogs/hive/00000_create_table.sql
new file mode 100644
index 0000000000..3eb1f5ff67
--- /dev/null
+++ b/integration-test/src/test/resources/trino-queries/catalogs/hive/00000_create_table.sql
@@ -0,0 +1,13 @@
+CREATE SCHEMA "test.hive".db1;
+
+CREATE TABLE "test.hive".db1.tb01 (
+ name varchar,
+ salary int
+)
+WITH (
+ format = 'TEXTFILE'
+);
+
+drop table "test.hive".db1.tb01;
+
+drop schema "test.hive".db1;
\ No newline at end of file
diff --git a/integration-test/src/test/resources/trino-queries/catalogs/hive/00000_create_table.txt b/integration-test/src/test/resources/trino-queries/catalogs/hive/00000_create_table.txt
new file mode 100644
index 0000000000..2862f23f23
--- /dev/null
+++ b/integration-test/src/test/resources/trino-queries/catalogs/hive/00000_create_table.txt
@@ -0,0 +1,7 @@
+CREATE SCHEMA
+
+CREATE TABLE
+
+DROP TABLE
+
+DROP SCHEMA
diff --git a/integration-test/src/test/resources/trino-queries/catalogs/hive/00001_select_table.sql b/integration-test/src/test/resources/trino-queries/catalogs/hive/00001_select_table.sql
new file mode 100644
index 0000000000..b7c1d8be80
--- /dev/null
+++ b/integration-test/src/test/resources/trino-queries/catalogs/hive/00001_select_table.sql
@@ -0,0 +1,33 @@
+CREATE SCHEMA "test.hive".db1;
+
+CREATE TABLE "test.hive".db1.tb01 (
+ name varchar,
+ salary int
+)
+WITH (
+ format = 'TEXTFILE'
+);
+
+insert into "test.hive".db1.tb01(name, salary) values ('sam', 11);
+insert into "test.hive".db1.tb01(name, salary) values ('jerry', 13);
+insert into "test.hive".db1.tb01(name, salary) values ('bob', 14), ('tom', 12);
+
+select distinct * from "test.hive".db1.tb01 order by name;
+
+CREATE TABLE "test.hive".db1.tb02 (
+ name varchar,
+ salary int
+)
+WITH (
+ format = 'TEXTFILE'
+);
+
+insert into "test.hive".db1.tb02(name, salary) select distinct * from "test.hive".db1.tb01 order by name;
+
+select distinct * from "test.hive".db1.tb02 order by name;
+
+drop table "test.hive".db1.tb02;
+
+drop table "test.hive".db1.tb01;
+
+drop schema "test.hive".db1;
diff --git a/integration-test/src/test/resources/trino-queries/catalogs/hive/00001_select_table.txt b/integration-test/src/test/resources/trino-queries/catalogs/hive/00001_select_table.txt
new file mode 100644
index 0000000000..f5aa32125e
--- /dev/null
+++ b/integration-test/src/test/resources/trino-queries/catalogs/hive/00001_select_table.txt
@@ -0,0 +1,31 @@
+CREATE SCHEMA
+
+CREATE TABLE
+
+INSERT: 1 row
+
+INSERT: 1 row
+
+INSERT: 2 rows
+
+"bob","14"
+"jerry","13"
+"sam","11"
+"tom","12"
+
+CREATE TABLE
+
+INSERT: 4 rows
+
+"bob","14"
+"jerry","13"
+"sam","11"
+"tom","12"
+
+DROP TABLE
+
+DROP TABLE
+
+DROP SCHEMA
+
+
diff --git a/integration-test/src/test/resources/trino-queries/catalogs/hive/00002_alter_table.sql b/integration-test/src/test/resources/trino-queries/catalogs/hive/00002_alter_table.sql
new file mode 100644
index 0000000000..e3ba75bad4
--- /dev/null
+++ b/integration-test/src/test/resources/trino-queries/catalogs/hive/00002_alter_table.sql
@@ -0,0 +1,35 @@
+CREATE SCHEMA "test.hive".db1;
+
+CREATE TABLE "test.hive".db1.tb01 (
+ name varchar,
+ salary int,
+ city int
+)
+WITH (
+ format = 'TEXTFILE'
+);
+
+alter table "test.hive".db1.tb01 rename to "test.hive".db1.tb03;
+show tables from "test.hive".db1;
+
+alter table "test.hive".db1.tb03 rename to "test.hive".db1.tb01;
+show tables from "test.hive".db1;
+
+alter table "test.hive".db1.tb01 drop column city;
+show create table "test.hive".db1.tb01;
+
+alter table "test.hive".db1.tb01 rename column name to s;
+show create table "test.hive".db1.tb01;
+
+alter table "test.hive".db1.tb01 alter column s set data type varchar(256);
+show create table "test.hive".db1.tb01;
+
+comment on table "test.hive".db1.tb01 is 'test table comments';
+show create table "test.hive".db1.tb01;
+
+comment on column "test.hive".db1.tb01.s is 'test column comments';
+show create table "test.hive".db1.tb01;
+
+drop table "test.hive".db1.tb01;
+
+drop schema "test.hive".db1;
diff --git a/integration-test/src/test/resources/trino-queries/catalogs/hive/00002_alter_table.txt b/integration-test/src/test/resources/trino-queries/catalogs/hive/00002_alter_table.txt
new file mode 100644
index 0000000000..c4bf08186e
--- /dev/null
+++ b/integration-test/src/test/resources/trino-queries/catalogs/hive/00002_alter_table.txt
@@ -0,0 +1,57 @@
+CREATE SCHEMA
+
+CREATE TABLE
+
+RENAME TABLE
+
+"tb03"
+
+RENAME TABLE
+
+"tb01"
+
+DROP COLUMN
+
+"CREATE TABLE ""test.hive"".db1.tb01 (
+ name varchar(65535),
+ salary integer
+)
+COMMENT ''"
+
+RENAME COLUMN
+
+"CREATE TABLE ""test.hive"".db1.tb01 (
+ s varchar(65535),
+ salary integer
+)
+COMMENT ''"
+
+SET COLUMN TYPE
+
+"CREATE TABLE ""test.hive"".db1.tb01 (
+ s varchar(256),
+ salary integer
+)
+COMMENT ''"
+
+COMMENT
+
+"CREATE TABLE ""test.hive"".db1.tb01 (
+ s varchar(256),
+ salary integer
+)
+COMMENT 'test table comments'"
+
+COMMENT
+
+"CREATE TABLE ""test.hive"".db1.tb01 (
+ s varchar(256) COMMENT 'test column comments',
+ salary integer
+)
+COMMENT 'test table comments'"
+
+DROP TABLE
+
+DROP SCHEMA
+
+
diff --git a/integration-test/src/test/resources/trino-queries/catalogs/lakehouse-iceberg/00000_create_table.sql b/integration-test/src/test/resources/trino-queries/catalogs/lakehouse-iceberg/00000_create_table.sql
new file mode 100644
index 0000000000..068e76238d
--- /dev/null
+++ b/integration-test/src/test/resources/trino-queries/catalogs/lakehouse-iceberg/00000_create_table.sql
@@ -0,0 +1,10 @@
+CREATE SCHEMA "test.lakehouse-iceberg".db2;
+
+CREATE TABLE "test.lakehouse-iceberg".db2.tb01 (
+ name varchar,
+ salary int
+);
+
+drop table "test.lakehouse-iceberg".db2.tb01;
+
+drop schema "test.lakehouse-iceberg".db2;
\ No newline at end of file
diff --git a/integration-test/src/test/resources/trino-queries/catalogs/lakehouse-iceberg/00000_create_table.txt b/integration-test/src/test/resources/trino-queries/catalogs/lakehouse-iceberg/00000_create_table.txt
new file mode 100644
index 0000000000..2862f23f23
--- /dev/null
+++ b/integration-test/src/test/resources/trino-queries/catalogs/lakehouse-iceberg/00000_create_table.txt
@@ -0,0 +1,7 @@
+CREATE SCHEMA
+
+CREATE TABLE
+
+DROP TABLE
+
+DROP SCHEMA
diff --git a/integration-test/src/test/resources/trino-queries/catalogs/lakehouse-iceberg/00001_select_table.sql b/integration-test/src/test/resources/trino-queries/catalogs/lakehouse-iceberg/00001_select_table.sql
new file mode 100644
index 0000000000..aa937fb457
--- /dev/null
+++ b/integration-test/src/test/resources/trino-queries/catalogs/lakehouse-iceberg/00001_select_table.sql
@@ -0,0 +1,28 @@
+CREATE SCHEMA "test.lakehouse-iceberg".db2;
+
+CREATE TABLE "test.lakehouse-iceberg".db2.tb01 (
+ name varchar,
+ salary int
+);
+
+
+insert into "test.lakehouse-iceberg".db2.tb01(name, salary) values ('sam', 11);
+insert into "test.lakehouse-iceberg".db2.tb01(name, salary) values ('jerry', 13);
+insert into "test.lakehouse-iceberg".db2.tb01(name, salary) values ('bob', 14), ('tom', 12);
+
+select distinct * from "test.lakehouse-iceberg".db2.tb01 order by name;
+
+CREATE TABLE "test.lakehouse-iceberg".db2.tb02 (
+ name varchar,
+ salary int
+);
+
+insert into "test.lakehouse-iceberg".db2.tb02(name, salary) select distinct * from "test.lakehouse-iceberg".db2.tb01 order by name;
+
+select distinct * from "test.lakehouse-iceberg".db2.tb02 order by name;
+
+drop table "test.lakehouse-iceberg".db2.tb02;
+
+drop table "test.lakehouse-iceberg".db2.tb01;
+
+drop schema "test.lakehouse-iceberg".db2;
diff --git a/integration-test/src/test/resources/trino-queries/catalogs/lakehouse-iceberg/00001_select_table.txt b/integration-test/src/test/resources/trino-queries/catalogs/lakehouse-iceberg/00001_select_table.txt
new file mode 100644
index 0000000000..f5aa32125e
--- /dev/null
+++ b/integration-test/src/test/resources/trino-queries/catalogs/lakehouse-iceberg/00001_select_table.txt
@@ -0,0 +1,31 @@
+CREATE SCHEMA
+
+CREATE TABLE
+
+INSERT: 1 row
+
+INSERT: 1 row
+
+INSERT: 2 rows
+
+"bob","14"
+"jerry","13"
+"sam","11"
+"tom","12"
+
+CREATE TABLE
+
+INSERT: 4 rows
+
+"bob","14"
+"jerry","13"
+"sam","11"
+"tom","12"
+
+DROP TABLE
+
+DROP TABLE
+
+DROP SCHEMA
+
+
diff --git a/integration-test/src/test/resources/trino-queries/catalogs/lakehouse-iceberg/00002_alter_table.sql b/integration-test/src/test/resources/trino-queries/catalogs/lakehouse-iceberg/00002_alter_table.sql
new file mode 100644
index 0000000000..3a41a06047
--- /dev/null
+++ b/integration-test/src/test/resources/trino-queries/catalogs/lakehouse-iceberg/00002_alter_table.sql
@@ -0,0 +1,32 @@
+CREATE SCHEMA "test.lakehouse-iceberg".db2;
+
+CREATE TABLE "test.lakehouse-iceberg".db2.tb01 (
+ name varchar,
+ salary int,
+ city int
+);
+
+alter table "test.lakehouse-iceberg".db2.tb01 rename to "test.lakehouse-iceberg".db2.tb03;
+show tables from "test.lakehouse-iceberg".db2;
+
+alter table "test.lakehouse-iceberg".db2.tb03 rename to "test.lakehouse-iceberg".db2.tb01;
+show tables from "test.lakehouse-iceberg".db2;
+
+alter table "test.lakehouse-iceberg".db2.tb01 drop column city;
+show create table "test.lakehouse-iceberg".db2.tb01;
+
+alter table "test.lakehouse-iceberg".db2.tb01 rename column name to s;
+show create table "test.lakehouse-iceberg".db2.tb01;
+
+alter table "test.lakehouse-iceberg".db2.tb01 alter column salary set data type bigint;
+show create table "test.lakehouse-iceberg".db2.tb01;
+
+comment on table "test.lakehouse-iceberg".db2.tb01 is 'test table comments';
+show create table "test.lakehouse-iceberg".db2.tb01;
+
+comment on column "test.lakehouse-iceberg".db2.tb01.s is 'test column comments';
+show create table "test.lakehouse-iceberg".db2.tb01;
+
+drop table "test.lakehouse-iceberg".db2.tb01;
+
+drop schema "test.lakehouse-iceberg".db2;
diff --git a/integration-test/src/test/resources/trino-queries/catalogs/lakehouse-iceberg/00002_alter_table.txt b/integration-test/src/test/resources/trino-queries/catalogs/lakehouse-iceberg/00002_alter_table.txt
new file mode 100644
index 0000000000..34204dd423
--- /dev/null
+++ b/integration-test/src/test/resources/trino-queries/catalogs/lakehouse-iceberg/00002_alter_table.txt
@@ -0,0 +1,57 @@
+CREATE SCHEMA
+
+CREATE TABLE
+
+RENAME TABLE
+
+"tb03"
+
+RENAME TABLE
+
+"tb01"
+
+DROP COLUMN
+
+"CREATE TABLE ""test.lakehouse-iceberg"".db2.tb01 (
+ name varchar,
+ salary integer
+)
+COMMENT ''"
+
+RENAME COLUMN
+
+"CREATE TABLE ""test.lakehouse-iceberg"".db2.tb01 (
+ s varchar,
+ salary integer
+)
+COMMENT ''"
+
+SET COLUMN TYPE
+
+"CREATE TABLE ""test.lakehouse-iceberg"".db2.tb01 (
+ s varchar,
+ salary bigint
+)
+COMMENT ''"
+
+COMMENT
+
+"CREATE TABLE ""test.lakehouse-iceberg"".db2.tb01 (
+ s varchar,
+ salary bigint
+)
+COMMENT 'test table comments'"
+
+COMMENT
+
+"CREATE TABLE ""test.lakehouse-iceberg"".db2.tb01 (
+ s varchar COMMENT 'test column comments',
+ salary bigint
+)
+COMMENT 'test table comments'"
+
+DROP TABLE
+
+DROP SCHEMA
+
+
diff --git a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/GravitinoMetadata.java b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/GravitinoMetadata.java
index b88fa3c1c7..277f9e577a 100644
--- a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/GravitinoMetadata.java
+++ b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/GravitinoMetadata.java
@@ -254,7 +254,7 @@ public class GravitinoMetadata implements ConnectorMetadata {
properties.entrySet().stream()
.filter(e -> e.getValue().isPresent())
.collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().get()));
- Map<String, String> allProps = metadataAdapter.toGravitonTableProperties(resultMap);
+ Map<String, String> allProps = metadataAdapter.toGravitinoTableProperties(resultMap);
catalogConnectorMetadata.setTableProperties(gravitinoTableHandle.toSchemaTableName(), allProps);
}
diff --git a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/CatalogConnectorFactory.java b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/CatalogConnectorFactory.java
index 0a513ec973..ecdf03c537 100644
--- a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/CatalogConnectorFactory.java
+++ b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/CatalogConnectorFactory.java
@@ -10,6 +10,7 @@ import static com.datastrato.gravitino.trino.connector.GravitinoErrorCode.GRAVIT
import com.datastrato.gravitino.NameIdentifier;
import com.datastrato.gravitino.client.GravitinoMetaLake;
import com.datastrato.gravitino.trino.connector.catalog.hive.HiveConnectorAdapter;
+import com.datastrato.gravitino.trino.connector.catalog.iceberg.IcebergConnectorAdapter;
import com.datastrato.gravitino.trino.connector.catalog.memory.MemoryConnectorAdapter;
import com.datastrato.gravitino.trino.connector.metadata.GravitinoCatalog;
import io.trino.spi.TrinoException;
@@ -31,6 +32,8 @@ public class CatalogConnectorFactory {
catalogBuilders.put("hive", new CatalogConnectorContext.Builder(new HiveConnectorAdapter()));
catalogBuilders.put(
"memory", new CatalogConnectorContext.Builder(new MemoryConnectorAdapter()));
+ catalogBuilders.put(
+ "lakehouse-iceberg", new CatalogConnectorContext.Builder(new IcebergConnectorAdapter()));
}
public CatalogConnectorContext loadCatalogConnector(
diff --git a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/CatalogConnectorManager.java b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/CatalogConnectorManager.java
index c2e52bcd46..9def786769 100644
--- a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/CatalogConnectorManager.java
+++ b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/CatalogConnectorManager.java
@@ -42,7 +42,7 @@ import org.slf4j.LoggerFactory;
public class CatalogConnectorManager {
private static final Logger LOG = LoggerFactory.getLogger(CatalogConnectorManager.class);
- private static final int CATALOG_LOAD_FREQUENCY_SECOND = 30;
+ private static final int CATALOG_LOAD_FREQUENCY_SECOND = 3;
private static final int NUMBER_EXECUTOR_THREAD = 1;
private final ScheduledExecutorService executorService;
diff --git a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/CatalogConnectorMetadata.java b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/CatalogConnectorMetadata.java
index f02a9cac7e..04732f9887 100644
--- a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/CatalogConnectorMetadata.java
+++ b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/CatalogConnectorMetadata.java
@@ -158,11 +158,21 @@ public class CatalogConnectorMetadata {
}
public void dropTable(SchemaTableName tableName) {
- boolean dropped =
- tableCatalog.dropTable(
- NameIdentifier.ofTable(
- metalake.name(), catalogName, tableName.getSchemaName(), tableName.getTableName()));
- if (!dropped) throw new TrinoException(GRAVITINO_TABLE_NOT_EXISTS, "Table does not exist");
+ try {
+ tableCatalog.purgeTable(
+ NameIdentifier.ofTable(
+ metalake.name(), catalogName, tableName.getSchemaName(), tableName.getTableName()));
+ } catch (UnsupportedOperationException e) {
+ LOG.warn("Purge table is not supported", e);
+ boolean dropped =
+ tableCatalog.dropTable(
+ NameIdentifier.ofTable(
+ metalake.name(),
+ catalogName,
+ tableName.getSchemaName(),
+ tableName.getTableName()));
+ if (!dropped) throw new TrinoException(GRAVITINO_TABLE_NOT_EXISTS, "Table does not exist");
+ }
}
public void renameSchema(String source, String target) {
@@ -180,7 +190,7 @@ public class CatalogConnectorMetadata {
} catch (IllegalArgumentException e) {
// TODO yuhui need improve get the error message. From IllegalArgumentException.
// At present, the IllegalArgumentException cannot get the error information clearly from the
- // Graviton server.
+ // Gravitino server.
String message =
e.getMessage().lines().toList().get(0) + e.getMessage().lines().toList().get(1);
throw new TrinoException(GRAVITINO_ILLEGAL_ARGUMENT, message, e);
diff --git a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/CatalogConnectorMetadataAdapter.java b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/CatalogConnectorMetadataAdapter.java
index 542fc37304..952444bcc8 100644
--- a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/CatalogConnectorMetadataAdapter.java
+++ b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/CatalogConnectorMetadataAdapter.java
@@ -71,7 +71,7 @@ public class CatalogConnectorMetadataAdapter {
String tableName = tableMetadata.getTableSchema().getTable().getTableName();
String schemaName = tableMetadata.getTableSchema().getTable().getSchemaName();
String comment = tableMetadata.getComment().orElse("");
- Map<String, String> properties = toGravitonTableProperties(tableMetadata.getProperties());
+ Map<String, String> properties = toGravitinoTableProperties(tableMetadata.getProperties());
List<GravitinoColumn> columns = new ArrayList<>();
for (int i = 0; i < tableMetadata.getColumns().size(); i++) {
@@ -134,7 +134,7 @@ public class CatalogConnectorMetadataAdapter {
}
/** Normalize trino table attributes for gravitino */
- public Map<String, String> toGravitonTableProperties(Map<String, Object> properties) {
+ public Map<String, String> toGravitinoTableProperties(Map<String, Object> properties) {
return removeUnsetProperties(properties);
}
diff --git a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/iceberg/IcebergConnectorAdapter.java b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/iceberg/IcebergConnectorAdapter.java
new file mode 100644
index 0000000000..6be3b4c0a1
--- /dev/null
+++ b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/iceberg/IcebergConnectorAdapter.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2023 Datastrato.
+ * This software is licensed under the Apache License version 2.
+ */
+package com.datastrato.gravitino.trino.connector.catalog.iceberg;
+
+import static java.util.Collections.emptyList;
+
+import com.datastrato.gravitino.trino.connector.catalog.CatalogConnectorAdapter;
+import com.datastrato.gravitino.trino.connector.catalog.CatalogConnectorMetadataAdapter;
+import com.datastrato.gravitino.trino.connector.metadata.GravitinoCatalog;
+import java.util.HashMap;
+import java.util.Map;
+
+/** Transforming Iceberg connector configuration and components into Gravitino connector. */
+public class IcebergConnectorAdapter implements CatalogConnectorAdapter {
+
+ // private final HiveTableProperties tableProperties =
+
+ public IcebergConnectorAdapter() {}
+
+ public Map<String, Object> buildInternalConnectorConfig(GravitinoCatalog catalog) {
+ Map<String, Object> config = new HashMap<>();
+ config.put("catalogHandle", catalog.getName() + ":normal:default");
+ config.put("connectorName", "iceberg");
+
+ Map<String, Object> properties = new HashMap<>();
+ properties.put("iceberg.catalog.type", "hive_metastore");
+ properties.put("hive.metastore.uri", catalog.getProperties("uri", ""));
+ config.put("properties", properties);
+ return config;
+ }
+
+ public CatalogConnectorMetadataAdapter getMetadataAdapter() {
+ // TODO yuhui Need to improve schema table and column properties
+ return new IcebergMetadataAdapter(getSchemaProperties(), getTableProperties(), emptyList());
+ }
+}
diff --git a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/iceberg/IcebergDataTypeTransformer.java b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/iceberg/IcebergDataTypeTransformer.java
new file mode 100644
index 0000000000..e5e5461eee
--- /dev/null
+++ b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/iceberg/IcebergDataTypeTransformer.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2023 Datastrato.
+ * This software is licensed under the Apache License version 2.
+ */
+
+package com.datastrato.gravitino.trino.connector.catalog.iceberg;
+
+import com.datastrato.gravitino.rel.types.Type;
+import com.datastrato.gravitino.rel.types.Type.Name;
+import com.datastrato.gravitino.rel.types.Types;
+import com.datastrato.gravitino.trino.connector.util.GeneralDataTypeTransformer;
+
+/** Type transformer between Iceberg and Trino */
+public class IcebergDataTypeTransformer extends GeneralDataTypeTransformer {
+
+ @Override
+ public Type getGravitinoType(io.trino.spi.type.Type type) {
+ Type gravitinoType = super.getGravitinoType(type);
+ if (gravitinoType.name() == Name.VARCHAR || gravitinoType.name() == Name.FIXEDCHAR) {
+ return Types.StringType.get();
+ }
+ return gravitinoType;
+ }
+}
diff --git a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/iceberg/IcebergMetadataAdapter.java b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/iceberg/IcebergMetadataAdapter.java
new file mode 100644
index 0000000000..64a0c9e3f2
--- /dev/null
+++ b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/iceberg/IcebergMetadataAdapter.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2023 Datastrato.
+ * This software is licensed under the Apache License version 2.
+ */
+package com.datastrato.gravitino.trino.connector.catalog.iceberg;
+
+import com.datastrato.gravitino.trino.connector.catalog.CatalogConnectorMetadataAdapter;
+import io.trino.spi.session.PropertyMetadata;
+import java.util.List;
+
+/** Transforming gravitino Iceberg metadata to trino. */
+public class IcebergMetadataAdapter extends CatalogConnectorMetadataAdapter {
+
+ public IcebergMetadataAdapter(
+ List<PropertyMetadata<?>> schemaProperties,
+ List<PropertyMetadata<?>> tableProperties,
+ List<PropertyMetadata<?>> columnProperties) {
+
+ super(schemaProperties, tableProperties, columnProperties, new IcebergDataTypeTransformer());
+ }
+}
diff --git a/trino-connector/src/test/java/com/datastrato/gravitino/trino/connector/GravitinoMockServer.java b/trino-connector/src/test/java/com/datastrato/gravitino/trino/connector/GravitinoMockServer.java
index 60a1ceb099..8067a72b41 100644
--- a/trino-connector/src/test/java/com/datastrato/gravitino/trino/connector/GravitinoMockServer.java
+++ b/trino-connector/src/test/java/com/datastrato/gravitino/trino/connector/GravitinoMockServer.java
@@ -49,7 +49,7 @@ import org.mockito.stubbing.Answer;
public class GravitinoMockServer implements AutoCloseable {
private final String testMetalake = "test";
private final String testCatalog = "memory";
- private final String testCatalogPrivate = "memory";
+ private final String testCatalogProvider = "memory";
private boolean start = true;
private CatalogConnectorManager catalogConnectorManager;
@@ -103,7 +103,7 @@ public class GravitinoMockServer implements AutoCloseable {
private Catalog createGravitinoCatalog(NameIdentifier catalogName) {
Catalog catalog = mock(Catalog.class);
when(catalog.name()).thenReturn(catalogName.name());
- when(catalog.provider()).thenReturn(testCatalogPrivate);
+ when(catalog.provider()).thenReturn(testCatalogProvider);
when(catalog.asTableCatalog()).thenAnswer(answer -> createTableCatalog(catalogName));
@@ -273,6 +273,9 @@ public class GravitinoMockServer implements AutoCloseable {
}
});
+ when(tableCatalog.purgeTable(any(NameIdentifier.class)))
+ .thenThrow(new UnsupportedOperationException());
+
when(tableCatalog.listTables(any(Namespace.class)))
.thenAnswer(
new Answer<NameIdentifier[]>() {