This is an automated email from the ASF dual-hosted git repository.
lzljs3620320 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/paimon.git
The following commit(s) were added to refs/heads/master by this push:
new 04d75278bb [hive] Batch list tables and skip checking table exists in
filesystem with hive catalog (#4737)
04d75278bb is described below
commit 04d75278bb2f2d1c021246d5a83ad8b8e4449840
Author: Zouxxyy <[email protected]>
AuthorDate: Thu Dec 19 09:53:41 2024 +0800
[hive] Batch list tables and skip checking table exists in filesystem with
hive catalog (#4737)
---
.../java/org/apache/paimon/hive/HiveCatalog.java | 28 +++++++---------------
1 file changed, 9 insertions(+), 19 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 975c1c0b7a..0be872a58c 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,17 +437,13 @@ public class HiveCatalog extends AbstractCatalog {
@Override
protected List<String> listTablesImpl(String databaseName) {
try {
- List<String> allTables = clients.run(client ->
client.getAllTables(databaseName));
- List<String> result = new ArrayList<>(allTables.size());
- for (String t : allTables) {
- try {
- Identifier identifier = new Identifier(databaseName, t);
- Table table = getHmsTable(identifier);
- if (isPaimonTable(identifier, table)
- || (!formatTableDisabled() &&
isFormatTable(table))) {
- result.add(t);
- }
- } catch (TableNotExistException ignored) {
+ List<String> tableNames = clients.run(client ->
client.getAllTables(databaseName));
+ List<Table> hmsTables =
+ clients.run(client ->
client.getTableObjectsByName(databaseName, tableNames));
+ List<String> result = new ArrayList<>(hmsTables.size());
+ for (Table table : hmsTables) {
+ if (isPaimonTable(table) || (!formatTableDisabled() &&
isFormatTable(table))) {
+ result.add(table.getTableName());
}
}
return result;
@@ -479,7 +475,7 @@ public class HiveCatalog extends AbstractCatalog {
private TableSchema getDataTableSchema(Identifier identifier, Table table)
throws TableNotExistException {
- if (!isPaimonTable(identifier, table)) {
+ if (!isPaimonTable(table)) {
throw new TableNotExistException(identifier);
}
@@ -876,7 +872,7 @@ public class HiveCatalog extends AbstractCatalog {
protected void alterTableImpl(Identifier identifier, List<SchemaChange>
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.");
}
@@ -1050,12 +1046,6 @@ public class HiveCatalog extends AbstractCatalog {
}
}
- 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())