From 9ffe615ef02b852cb298e275709ac8405fe0758f Mon Sep 17 00:00:00 2001 From: zouxxyy Date: Wed, 18 Dec 2024 18:44:45 +0800 Subject: [PATCH 1/3] [hive] Skip checking table exists in filesystem when show tables --- .../java/org/apache/paimon/hive/HiveCatalog.java | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalog.java b/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalog.java index a590ede6d2e6..7d396954cf95 100644 --- a/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalog.java +++ b/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalog.java @@ -442,8 +442,7 @@ protected List listTablesImpl(String databaseName) { try { Identifier identifier = new Identifier(databaseName, t); Table table = getHmsTable(identifier); - if (isPaimonTable(identifier, table) - || (!formatTableDisabled() && isFormatTable(table))) { + if (isPaimonTable(table) || (!formatTableDisabled() && isFormatTable(table))) { result.add(t); } } catch (TableNotExistException ignored) { @@ -478,7 +477,7 @@ public TableSchema getDataTableSchema(Identifier identifier) throws TableNotExis private TableSchema getDataTableSchema(Identifier identifier, Table table) throws TableNotExistException { - if (!isPaimonTable(identifier, table)) { + if (!isPaimonTable(table)) { throw new TableNotExistException(identifier); } @@ -870,7 +869,7 @@ private Table renameHiveTable(Identifier fromTable, Identifier toTable) { protected void alterTableImpl(Identifier identifier, List changes) throws TableNotExistException, ColumnAlreadyExistException, ColumnNotExistException { Table table = getHmsTable(identifier); - if (!isPaimonTable(identifier, table)) { + if (!isPaimonTable(table)) { throw new UnsupportedOperationException("Only data table support alter table."); } @@ -1044,12 +1043,6 @@ public Table getHmsTable(Identifier identifier) throws TableNotExistException { } } - private boolean isPaimonTable(Identifier identifier, Table table) { - return isPaimonTable(table) - && tableExistsInFileSystem( - getTableLocation(identifier, table), identifier.getBranchNameOrDefault()); - } - private static boolean isPaimonTable(Table table) { boolean isPaimonTable = INPUT_FORMAT_CLASS_NAME.equals(table.getSd().getInputFormat()) From f925d835459ae51fa776be26cb1c979750989f8d Mon Sep 17 00:00:00 2001 From: zouxxyy Date: Wed, 18 Dec 2024 19:33:28 +0800 Subject: [PATCH 2/3] add batch list --- .../java/org/apache/paimon/hive/HiveCatalog.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalog.java b/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalog.java index 7d396954cf95..743f629281fe 100644 --- a/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalog.java +++ b/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalog.java @@ -437,15 +437,12 @@ protected void alterDatabaseImpl(String name, List changes) { protected List listTablesImpl(String databaseName) { try { List allTables = clients.run(client -> client.getAllTables(databaseName)); + List hmsTables = + clients.run(client -> client.getTableObjectsByName(databaseName, allTables)); List result = new ArrayList<>(allTables.size()); - for (String t : allTables) { - try { - Identifier identifier = new Identifier(databaseName, t); - Table table = getHmsTable(identifier); - if (isPaimonTable(table) || (!formatTableDisabled() && isFormatTable(table))) { - result.add(t); - } - } catch (TableNotExistException ignored) { + for (Table table : hmsTables) { + if (isPaimonTable(table) || (!formatTableDisabled() && isFormatTable(table))) { + result.add(table.getTableName()); } } return result; From ae9e57e20cfce05217e6c31800c6be2d0e7a2474 Mon Sep 17 00:00:00 2001 From: zouxxyy Date: Wed, 18 Dec 2024 19:34:42 +0800 Subject: [PATCH 3/3] 1 --- .../src/main/java/org/apache/paimon/hive/HiveCatalog.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalog.java b/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalog.java index 743f629281fe..78ab31ab9823 100644 --- a/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalog.java +++ b/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalog.java @@ -436,10 +436,10 @@ protected void alterDatabaseImpl(String name, List changes) { @Override protected List listTablesImpl(String databaseName) { try { - List allTables = clients.run(client -> client.getAllTables(databaseName)); + List tableNames = clients.run(client -> client.getAllTables(databaseName)); List
hmsTables = - clients.run(client -> client.getTableObjectsByName(databaseName, allTables)); - List result = new ArrayList<>(allTables.size()); + clients.run(client -> client.getTableObjectsByName(databaseName, tableNames)); + List result = new ArrayList<>(hmsTables.size()); for (Table table : hmsTables) { if (isPaimonTable(table) || (!formatTableDisabled() && isFormatTable(table))) { result.add(table.getTableName());