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 c7dfcfa18 [core] Partitions system table support time travel (#4511)
c7dfcfa18 is described below

commit c7dfcfa18411af1511035b1481229499008eda05
Author: zhangdong <[email protected]>
AuthorDate: Wed Nov 13 17:05:24 2024 +0800

    [core] Partitions system table support time travel (#4511)
---
 .../paimon/table/system/PartitionsTable.java       |  2 +-
 .../paimon/table/system/PartitionsTableTest.java   | 24 +++++++++++++++++++---
 2 files changed, 22 insertions(+), 4 deletions(-)

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 736347b9a..7e0b1f1d7 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
@@ -178,7 +178,7 @@ public class PartitionsTable implements ReadonlyTable {
                 throw new IllegalArgumentException("Unsupported split: " + 
split.getClass());
             }
 
-            List<PartitionEntry> partitions = 
fileStoreTable.newSnapshotReader().partitionEntries();
+            List<PartitionEntry> partitions = 
fileStoreTable.newScan().listPartitionEntries();
 
             RowDataToObjectArrayConverter converter =
                     new RowDataToObjectArrayConverter(
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 a17dc7546..8d12dc707 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
@@ -40,6 +40,7 @@ import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
 import static org.assertj.core.api.Assertions.assertThat;
@@ -76,7 +77,7 @@ public class PartitionsTableTest extends TableTestBase {
         partitionsTable = (PartitionsTable) catalog.getTable(filesTableId);
 
         // snapshot 1: append
-        write(table, GenericRow.of(1, 1, 1), GenericRow.of(1, 2, 5));
+        write(table, GenericRow.of(1, 1, 1), GenericRow.of(1, 3, 5));
 
         write(table, GenericRow.of(1, 1, 3), GenericRow.of(1, 2, 4));
     }
@@ -85,19 +86,36 @@ public class PartitionsTableTest extends TableTestBase {
     public void testPartitionRecordCount() throws Exception {
         List<InternalRow> expectedRow = new ArrayList<>();
         expectedRow.add(GenericRow.of(BinaryString.fromString("[1]"), 2L));
-        expectedRow.add(GenericRow.of(BinaryString.fromString("[2]"), 2L));
+        expectedRow.add(GenericRow.of(BinaryString.fromString("[2]"), 1L));
+        expectedRow.add(GenericRow.of(BinaryString.fromString("[3]"), 1L));
 
         // Only read partition and record count, record size may not stable.
         List<InternalRow> result = read(partitionsTable, new int[][] {{0}, 
{1}});
         assertThat(result).containsExactlyInAnyOrderElementsOf(expectedRow);
     }
 
+    @Test
+    public void testPartitionTimeTravel() throws Exception {
+        List<InternalRow> expectedRow = new ArrayList<>();
+        expectedRow.add(GenericRow.of(BinaryString.fromString("[1]"), 1L));
+        expectedRow.add(GenericRow.of(BinaryString.fromString("[3]"), 1L));
+
+        // Only read partition and record count, record size may not stable.
+        List<InternalRow> result =
+                read(
+                        partitionsTable.copy(
+                                
Collections.singletonMap(CoreOptions.SCAN_VERSION.key(), "1")),
+                        new int[][] {{0}, {1}});
+        assertThat(result).containsExactlyInAnyOrderElementsOf(expectedRow);
+    }
+
     @Test
     public void testPartitionValue() throws Exception {
         write(table, GenericRow.of(2, 1, 3), GenericRow.of(3, 1, 4));
         List<InternalRow> expectedRow = new ArrayList<>();
         expectedRow.add(GenericRow.of(BinaryString.fromString("[1]"), 4L, 3L));
-        expectedRow.add(GenericRow.of(BinaryString.fromString("[2]"), 2L, 2L));
+        expectedRow.add(GenericRow.of(BinaryString.fromString("[2]"), 1L, 1L));
+        expectedRow.add(GenericRow.of(BinaryString.fromString("[3]"), 1L, 1L));
 
         List<InternalRow> result = read(partitionsTable, new int[][] {{0}, 
{1}, {3}});
         assertThat(result).containsExactlyInAnyOrderElementsOf(expectedRow);

Reply via email to