This is an automated email from the ASF dual-hosted git repository.

yuzelin 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 6af6711934 [core] Add listTableDetails method to Catalog interface 
(#7266)
6af6711934 is described below

commit 6af6711934ca3dcf52708e44077f0298fe4f7ee5
Author: tsreaper <[email protected]>
AuthorDate: Wed Feb 11 18:05:50 2026 +0800

    [core] Add listTableDetails method to Catalog interface (#7266)
---
 .../main/java/org/apache/paimon/rest/RESTApi.java  | 22 ++++++++++++++++++
 .../org/apache/paimon/catalog/AbstractCatalog.java | 13 +++++++++++
 .../java/org/apache/paimon/catalog/Catalog.java    | 11 +++++++++
 .../org/apache/paimon/catalog/DelegateCatalog.java |  5 +++++
 .../java/org/apache/paimon/rest/RESTCatalog.java   | 10 +++++++++
 .../org/apache/paimon/rest/RESTCatalogTest.java    | 26 ++++++++++++++++++++++
 6 files changed, 87 insertions(+)

diff --git a/paimon-api/src/main/java/org/apache/paimon/rest/RESTApi.java 
b/paimon-api/src/main/java/org/apache/paimon/rest/RESTApi.java
index e135ef17a2..bfa0b5cb50 100644
--- a/paimon-api/src/main/java/org/apache/paimon/rest/RESTApi.java
+++ b/paimon-api/src/main/java/org/apache/paimon/rest/RESTApi.java
@@ -420,6 +420,28 @@ public class RESTApi {
         return new PagedList<>(tables, response.getNextPageToken());
     }
 
+    /**
+     * List table details for a database.
+     *
+     * <p>Gets an array of table details for a database. There is no guarantee 
of a specific
+     * ordering of the elements in the array.
+     *
+     * @param databaseName name of database.
+     * @return a list of table details.
+     * @throws NoSuchResourceException Exception thrown on HTTP 404 means the 
database not exists
+     * @throws ForbiddenException Exception thrown on HTTP 403 means don't 
have the permission for
+     *     this database
+     */
+    public List<GetTableResponse> listTableDetails(String databaseName) {
+        return listDataFromPageApi(
+                queryParams ->
+                        client.get(
+                                resourcePaths.tableDetails(databaseName),
+                                queryParams,
+                                ListTableDetailsResponse.class,
+                                restAuthFunction));
+    }
+
     /**
      * List table for a catalog.
      *
diff --git 
a/paimon-core/src/main/java/org/apache/paimon/catalog/AbstractCatalog.java 
b/paimon-core/src/main/java/org/apache/paimon/catalog/AbstractCatalog.java
index 740b52e7a1..fb6fe21ac3 100644
--- a/paimon-core/src/main/java/org/apache/paimon/catalog/AbstractCatalog.java
+++ b/paimon-core/src/main/java/org/apache/paimon/catalog/AbstractCatalog.java
@@ -330,6 +330,19 @@ public abstract class AbstractCatalog implements Catalog {
                 pagedTableNames.getNextPageToken());
     }
 
+    @Override
+    public List<Table> listTableDetails(String databaseName) throws 
DatabaseNotExistException {
+        List<Table> result = new ArrayList<>();
+        for (String tableName : listTables(databaseName)) {
+            try {
+                result.add(getTable(Identifier.create(databaseName, 
tableName)));
+            } catch (TableNotExistException e) {
+                // ignore
+            }
+        }
+        return result;
+    }
+
     @Override
     public void dropTable(Identifier identifier, boolean ignoreIfNotExists)
             throws TableNotExistException {
diff --git a/paimon-core/src/main/java/org/apache/paimon/catalog/Catalog.java 
b/paimon-core/src/main/java/org/apache/paimon/catalog/Catalog.java
index 192dbd33ac..72d35c7a76 100644
--- a/paimon-core/src/main/java/org/apache/paimon/catalog/Catalog.java
+++ b/paimon-core/src/main/java/org/apache/paimon/catalog/Catalog.java
@@ -232,6 +232,17 @@ public interface Catalog extends AutoCloseable {
             @Nullable String tableType)
             throws DatabaseNotExistException;
 
+    /**
+     * Get list of table details under this database. An empty list is 
returned if none exists.
+     *
+     * <p>NOTE: System tables will not be listed.
+     *
+     * @param databaseName Name of the database to list table details.
+     * @return a list of the details of all tables in this database.
+     * @throws DatabaseNotExistException if the database does not exist
+     */
+    List<Table> listTableDetails(String databaseName) throws 
DatabaseNotExistException;
+
     /**
      * Gets an array of tables for a catalog.
      *
diff --git 
a/paimon-core/src/main/java/org/apache/paimon/catalog/DelegateCatalog.java 
b/paimon-core/src/main/java/org/apache/paimon/catalog/DelegateCatalog.java
index 623993444f..12505698db 100644
--- a/paimon-core/src/main/java/org/apache/paimon/catalog/DelegateCatalog.java
+++ b/paimon-core/src/main/java/org/apache/paimon/catalog/DelegateCatalog.java
@@ -126,6 +126,11 @@ public abstract class DelegateCatalog implements Catalog {
                 databaseName, maxResults, pageToken, tableNamePattern, 
tableType);
     }
 
+    @Override
+    public List<Table> listTableDetails(String databaseName) throws 
DatabaseNotExistException {
+        return wrapped.listTableDetails(databaseName);
+    }
+
     @Override
     public PagedList<Identifier> listTablesPagedGlobally(
             String databaseNamePattern,
diff --git a/paimon-core/src/main/java/org/apache/paimon/rest/RESTCatalog.java 
b/paimon-core/src/main/java/org/apache/paimon/rest/RESTCatalog.java
index 46262601d8..30e53de66b 100644
--- a/paimon-core/src/main/java/org/apache/paimon/rest/RESTCatalog.java
+++ b/paimon-core/src/main/java/org/apache/paimon/rest/RESTCatalog.java
@@ -266,6 +266,16 @@ public class RESTCatalog implements Catalog {
         }
     }
 
+    @Override
+    public List<Table> listTableDetails(String databaseName) throws 
DatabaseNotExistException {
+        try {
+            List<GetTableResponse> tables = api.listTableDetails(databaseName);
+            return tables.stream().map(t -> toTable(databaseName, 
t)).collect(Collectors.toList());
+        } catch (NoSuchResourceException e) {
+            throw new DatabaseNotExistException(databaseName);
+        }
+    }
+
     @Override
     public PagedList<Identifier> listTablesPagedGlobally(
             @Nullable String databaseNamePattern,
diff --git 
a/paimon-core/src/test/java/org/apache/paimon/rest/RESTCatalogTest.java 
b/paimon-core/src/test/java/org/apache/paimon/rest/RESTCatalogTest.java
index 2bf7d25a8c..8c5fdf5459 100644
--- a/paimon-core/src/test/java/org/apache/paimon/rest/RESTCatalogTest.java
+++ b/paimon-core/src/test/java/org/apache/paimon/rest/RESTCatalogTest.java
@@ -736,6 +736,32 @@ public abstract class RESTCatalogTest extends 
CatalogTestBase {
         assertThat(nonExistentTypeWithMaxResults.getNextPageToken()).isNull();
     }
 
+    @Test
+    public void testListTableDetails() throws Exception {
+        // List table details returns an empty list when there are no tables 
in the database
+        String databaseName = "table_details_db";
+        catalog.createDatabase(databaseName, false);
+        List<Table> tableDetails = catalog.listTableDetails(databaseName);
+        assertThat(tableDetails).isEmpty();
+
+        String[] tableNames = {"table1", "table2", "table3", "abd", "def", 
"opr", "table_name"};
+        String[] expectedTableNames = 
Arrays.stream(tableNames).sorted().toArray(String[]::new);
+        for (String tableName : tableNames) {
+            catalog.createTable(
+                    Identifier.create(databaseName, tableName), 
DEFAULT_TABLE_SCHEMA, false);
+        }
+
+        tableDetails = catalog.listTableDetails(databaseName);
+        assertThat(tableDetails).hasSize(tableNames.length);
+        List<String> actualTableNames =
+                
tableDetails.stream().map(Table::name).sorted().collect(Collectors.toList());
+        assertThat(actualTableNames).containsExactly(expectedTableNames);
+
+        // List table details throws DatabaseNotExistException when the 
database does not exist
+        assertThatExceptionOfType(Catalog.DatabaseNotExistException.class)
+                .isThrownBy(() -> catalog.listTableDetails("non_existing_db"));
+    }
+
     @Test
     public void testListTablesPagedWithTableType() throws Exception {
         String databaseName = "tables_paged_table_type_db";

Reply via email to