From 909b6ba2c6cdac0067702df33e733f8d6ed6561e Mon Sep 17 00:00:00 2001 From: morningman Date: Thu, 5 Feb 2026 18:28:51 +0800 Subject: [PATCH 1/2] [kudu] do not use write --- .../SchemaEmulationByTableNameConvention.java | 71 +++++++++---------- 1 file changed, 34 insertions(+), 37 deletions(-) diff --git a/plugin/trino-kudu/src/main/java/io/trino/plugin/kudu/schema/SchemaEmulationByTableNameConvention.java b/plugin/trino-kudu/src/main/java/io/trino/plugin/kudu/schema/SchemaEmulationByTableNameConvention.java index 733ee57e7af..cf449b08a08 100644 --- a/plugin/trino-kudu/src/main/java/io/trino/plugin/kudu/schema/SchemaEmulationByTableNameConvention.java +++ b/plugin/trino-kudu/src/main/java/io/trino/plugin/kudu/schema/SchemaEmulationByTableNameConvention.java @@ -25,13 +25,9 @@ import org.apache.kudu.client.Delete; import org.apache.kudu.client.KuduException; import org.apache.kudu.client.KuduOperationApplier; -import org.apache.kudu.client.KuduScanner; import org.apache.kudu.client.KuduTable; -import org.apache.kudu.client.RowResult; -import org.apache.kudu.client.RowResultIterator; import org.apache.kudu.client.Upsert; -import java.util.ArrayList; import java.util.LinkedHashSet; import java.util.List; @@ -113,40 +109,41 @@ public void dropSchema(KuduClientWrapper client, String schemaName, boolean casc public List listSchemaNames(KuduClientWrapper client) { try { - if (rawSchemasTable == null) { - // Try to open the schemas table first, only create if it doesn't exist - try { - rawSchemasTable = client.openTable(rawSchemasTableName); - } - catch (KuduException e) { - if (e.getStatus().isNotFound()) { - // Table doesn't exist, try to create it (requires write permission) - // If creation fails due to permission, fall back to scanning table names - try { - createAndFillSchemasTable(client); - rawSchemasTable = getSchemasTable(client); - } - catch (KuduException createException) { - // Fall back to listing schemas from table names directly (read-only) - return listSchemaNamesFromTablets(client); - } - } - else { - throw e; - } - } - } + // if (rawSchemasTable == null) { + // // Try to open the schemas table first, only create if it doesn't exist + // try { + // rawSchemasTable = client.openTable(rawSchemasTableName); + // } + // catch (KuduException e) { + // if (e.getStatus().isNotFound()) { + // // Table doesn't exist, try to create it (requires write permission) + // // If creation fails due to permission, fall back to scanning table names + // try { + // createAndFillSchemasTable(client); + // rawSchemasTable = getSchemasTable(client); + // } + // catch (KuduException createException) { + // // Fall back to listing schemas from table names directly (read-only) + // return listSchemaNamesFromTablets(client); + // } + // } + // else { + // throw e; + // } + // } + // } - KuduScanner scanner = client.newScannerBuilder(rawSchemasTable).build(); - RowResultIterator iterator = scanner.nextRows(); - ArrayList result = new ArrayList<>(); - while (iterator != null) { - for (RowResult row : iterator) { - result.add(row.getString(0)); - } - iterator = scanner.nextRows(); - } - return result; + // KuduScanner scanner = client.newScannerBuilder(rawSchemasTable).build(); + // RowResultIterator iterator = scanner.nextRows(); + // ArrayList result = new ArrayList<>(); + // while (iterator != null) { + // for (RowResult row : iterator) { + // result.add(row.getString(0)); + // } + // iterator = scanner.nextRows(); + // } + // return result; + return listSchemaNamesFromTablets(client); } catch (KuduException e) { throw new TrinoException(GENERIC_INTERNAL_ERROR, e); From b8bc2d598ced568ae9ac31768a3406e3395e95b7 Mon Sep 17 00:00:00 2001 From: morningman Date: Sat, 7 Feb 2026 01:12:40 +0800 Subject: [PATCH 2/2] [kudu] fix write priv issue --- .../SchemaEmulationByTableNameConvention.java | 39 +++---------------- 1 file changed, 5 insertions(+), 34 deletions(-) diff --git a/plugin/trino-kudu/src/main/java/io/trino/plugin/kudu/schema/SchemaEmulationByTableNameConvention.java b/plugin/trino-kudu/src/main/java/io/trino/plugin/kudu/schema/SchemaEmulationByTableNameConvention.java index cf449b08a08..2d7c3aaf9a4 100644 --- a/plugin/trino-kudu/src/main/java/io/trino/plugin/kudu/schema/SchemaEmulationByTableNameConvention.java +++ b/plugin/trino-kudu/src/main/java/io/trino/plugin/kudu/schema/SchemaEmulationByTableNameConvention.java @@ -109,40 +109,11 @@ public void dropSchema(KuduClientWrapper client, String schemaName, boolean casc public List listSchemaNames(KuduClientWrapper client) { try { - // if (rawSchemasTable == null) { - // // Try to open the schemas table first, only create if it doesn't exist - // try { - // rawSchemasTable = client.openTable(rawSchemasTableName); - // } - // catch (KuduException e) { - // if (e.getStatus().isNotFound()) { - // // Table doesn't exist, try to create it (requires write permission) - // // If creation fails due to permission, fall back to scanning table names - // try { - // createAndFillSchemasTable(client); - // rawSchemasTable = getSchemasTable(client); - // } - // catch (KuduException createException) { - // // Fall back to listing schemas from table names directly (read-only) - // return listSchemaNamesFromTablets(client); - // } - // } - // else { - // throw e; - // } - // } - // } - - // KuduScanner scanner = client.newScannerBuilder(rawSchemasTable).build(); - // RowResultIterator iterator = scanner.nextRows(); - // ArrayList result = new ArrayList<>(); - // while (iterator != null) { - // for (RowResult row : iterator) { - // result.add(row.getString(0)); - // } - // iterator = scanner.nextRows(); - // } - // return result; + // createAndFillSchemasTable(client); + // rawSchemasTable = getSchemasTable(client); + // ATTN, sometimes user does not have write priv for kudu, + // so we can not create schema table here. + // So here we get schema names directly from tablets. return listSchemaNamesFromTablets(client); } catch (KuduException e) {