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

JingsongLi 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 7068c736d2 [core] Expose total_buckets and done columns in 
PartitionsTable system table (#7785)
7068c736d2 is described below

commit 7068c736d2e56d8413667adaef42a37d6b042e8b
Author: Jiajia Li <[email protected]>
AuthorDate: Fri May 8 22:27:27 2026 +0800

    [core] Expose total_buckets and done columns in PartitionsTable system 
table (#7785)
    
    Add two new columns to the $partitions system table:
    
    - num_buckets (INT): number of buckets in the partition, sourced from
    PartitionStatistics.totalBuckets()
    
    - done (BOOLEAN): whether the partition has been marked done, sourced
    from Partition.done()
---
 docs/content/concepts/system-tables.md                    | 10 +++++-----
 .../org/apache/paimon/table/system/PartitionsTable.java   |  8 ++++++--
 .../apache/paimon/table/system/PartitionsTableTest.java   | 15 ++++++++++++++-
 3 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/docs/content/concepts/system-tables.md 
b/docs/content/concepts/system-tables.md
index 5d90b590d4..2eb2fc73c3 100644
--- a/docs/content/concepts/system-tables.md
+++ b/docs/content/concepts/system-tables.md
@@ -432,11 +432,11 @@ You can query the partition files of the table.
 SELECT * FROM my_table$partitions;
 
 /*
-+-----------+--------------+-------------------+------------+---------------------+---------------------+------------+------------+---------+
-| partition | record_count | file_size_in_bytes| file_count | last_update_time 
   | created_at          | created_by | updated_by | options |
-+-----------+--------------+-------------------+------------+---------------------+---------------------+------------+------------+---------+
-| {1}       |            1 |               645 |          1 | 2024-06-24 
10:25:57 | 2024-06-24 10:20:00 | admin      | test_user  | {}      |
-+-----------+--------------+-------------------+------------+---------------------+---------------------+------------+------------+---------+
++-----------+--------------+-------------------+------------+---------------------+---------------------+------------+------------+---------+---------------+-------+
+| partition | record_count | file_size_in_bytes| file_count | last_update_time 
   | created_at          | created_by | updated_by | options | total_buckets | 
done  |
++-----------+--------------+-------------------+------------+---------------------+---------------------+------------+------------+---------+---------------+-------+
+| {1}       |            1 |               645 |          1 | 2024-06-24 
10:25:57 | 2024-06-24 10:20:00 | admin      | test_user  | {}      |            
 1 | false |
++-----------+--------------+-------------------+------------+---------------------+---------------------+------------+------------+---------+---------------+-------+
 */
 ```
 
diff --git 
a/paimon-core/src/main/java/org/apache/paimon/table/system/PartitionsTable.java 
b/paimon-core/src/main/java/org/apache/paimon/table/system/PartitionsTable.java
index 296542d70a..a165eb5185 100644
--- 
a/paimon-core/src/main/java/org/apache/paimon/table/system/PartitionsTable.java
+++ 
b/paimon-core/src/main/java/org/apache/paimon/table/system/PartitionsTable.java
@@ -95,7 +95,9 @@ public class PartitionsTable implements ReadonlyTable {
                             new DataField(5, "created_at", 
DataTypes.TIMESTAMP_MILLIS()),
                             new DataField(6, "created_by", DataTypes.STRING()),
                             new DataField(7, "updated_by", DataTypes.STRING()),
-                            new DataField(8, "options", DataTypes.STRING())));
+                            new DataField(8, "options", DataTypes.STRING()),
+                            new DataField(9, "total_buckets", 
DataTypes.INT().notNull()),
+                            new DataField(10, "done", 
DataTypes.BOOLEAN().notNull())));
 
     private final FileStoreTable storeTable;
 
@@ -291,7 +293,9 @@ public class PartitionsTable implements ReadonlyTable {
                     createdAtTimestamp,
                     createdByString,
                     updatedByString,
-                    optionsString);
+                    optionsString,
+                    partition.totalBuckets(),
+                    partition.done());
         }
 
         private PartitionEntry toPartitionEntry(Partition partition) {
diff --git 
a/paimon-core/src/test/java/org/apache/paimon/table/system/PartitionsTableTest.java
 
b/paimon-core/src/test/java/org/apache/paimon/table/system/PartitionsTableTest.java
index 8091288c60..d70fe0d666 100644
--- 
a/paimon-core/src/test/java/org/apache/paimon/table/system/PartitionsTableTest.java
+++ 
b/paimon-core/src/test/java/org/apache/paimon/table/system/PartitionsTableTest.java
@@ -123,7 +123,7 @@ public class PartitionsTableTest extends TableTestBase {
 
     @Test
     void testPartitionAuditFieldsNull() throws Exception {
-        List<InternalRow> result = read(partitionsTable, new int[] {0, 5, 6, 
7, 8});
+        List<InternalRow> result = read(partitionsTable, new int[] {0, 5, 6, 
7, 8, 10});
         assertThat(result).hasSize(3);
 
         for (InternalRow row : result) {
@@ -131,9 +131,22 @@ public class PartitionsTableTest extends TableTestBase {
             assertThat(row.isNullAt(2)).isTrue(); //  created_by
             assertThat(row.isNullAt(3)).isTrue(); // updated_by
             assertThat(row.isNullAt(4)).isTrue(); // options
+            assertThat(row.getBoolean(5)).isFalse(); // done
         }
     }
 
+    @Test
+    public void testPartitionTotalBuckets() throws Exception {
+        List<InternalRow> expectedRow = new ArrayList<>();
+        expectedRow.add(GenericRow.of(BinaryString.fromString("pt=1"), 1));
+        expectedRow.add(GenericRow.of(BinaryString.fromString("pt=2"), 1));
+        expectedRow.add(GenericRow.of(BinaryString.fromString("pt=3"), 1));
+
+        // Read partition and total_buckets columns; the table is configured 
with bucket=1.
+        List<InternalRow> result = read(partitionsTable, new int[] {0, 9});
+        assertThat(result).containsExactlyInAnyOrderElementsOf(expectedRow);
+    }
+
     @Test
     void testPartitionWithLegacyPartitionName() throws Exception {
         String testTableName = "TestLegacyTable";

Reply via email to