diff --git a/paimon-core/src/main/java/org/apache/paimon/table/system/TagsTable.java b/paimon-core/src/main/java/org/apache/paimon/table/system/TagsTable.java index 5a179cfc1d72..0c1c4aa29925 100644 --- a/paimon-core/src/main/java/org/apache/paimon/table/system/TagsTable.java +++ b/paimon-core/src/main/java/org/apache/paimon/table/system/TagsTable.java @@ -18,7 +18,6 @@ package org.apache.paimon.table.system; -import org.apache.paimon.CoreOptions; import org.apache.paimon.data.BinaryString; import org.apache.paimon.data.GenericRow; import org.apache.paimon.data.InternalRow; @@ -26,11 +25,8 @@ import org.apache.paimon.disk.IOManager; import org.apache.paimon.fs.FileIO; import org.apache.paimon.fs.Path; -import org.apache.paimon.options.Options; import org.apache.paimon.predicate.Predicate; import org.apache.paimon.reader.RecordReader; -import org.apache.paimon.table.FileStoreTable; -import org.apache.paimon.table.FileStoreTableFactory; import org.apache.paimon.table.ReadonlyTable; import org.apache.paimon.table.Table; import org.apache.paimon.table.source.InnerTableRead; @@ -52,10 +48,8 @@ import org.apache.paimon.shade.guava30.com.google.common.collect.Iterators; -import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; -import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; @@ -80,10 +74,9 @@ public class TagsTable implements ReadonlyTable { new DataField(2, "schema_id", new BigIntType(false)), new DataField(3, "commit_time", new TimestampType(false, 3)), new DataField(4, "record_count", new BigIntType(true)), - new DataField(5, "branches", SerializationUtils.newStringType(true)), - new DataField(6, "create_time", new TimestampType(true, 3)), + new DataField(5, "create_time", new TimestampType(true, 3)), new DataField( - 7, "time_retained", SerializationUtils.newStringType(true)))); + 6, "time_retained", SerializationUtils.newStringType(true)))); private final FileIO fileIO; private final Path location; @@ -140,6 +133,7 @@ public Plan innerPlan() { } private static class TagsSplit implements Split { + private static final long serialVersionUID = 1L; private final long rowCount; @@ -205,28 +199,14 @@ public RecordReader createReader(Split split) { throw new IllegalArgumentException("Unsupported split: " + split.getClass()); } Path location = ((TagsSplit) split).location; - Options options = new Options(); - options.set(CoreOptions.PATH, location.toUri().toString()); - FileStoreTable table = FileStoreTableFactory.create(fileIO, options); - List> tags = table.tagManager().tagObjects(); + List> tags = new TagManager(fileIO, location).tagObjects(); Map nameToSnapshot = new LinkedHashMap<>(); for (Pair tag : tags) { nameToSnapshot.put(tag.getValue(), tag.getKey()); } - Map> tagBranches = new HashMap<>(); - table.branchManager() - .branches() - .forEach( - branch -> - tagBranches - .computeIfAbsent( - branch.getCreatedFromTag(), - key -> new ArrayList<>()) - .add(branch.getBranchName())); Iterator rows = - Iterators.transform( - nameToSnapshot.entrySet().iterator(), tag -> toRow(tag, tagBranches)); + Iterators.transform(nameToSnapshot.entrySet().iterator(), this::toRow); if (projection != null) { rows = Iterators.transform( @@ -235,17 +215,14 @@ public RecordReader createReader(Split split) { return new IteratorRecordReader<>(rows); } - private InternalRow toRow( - Map.Entry snapshot, Map> tagBranches) { + private InternalRow toRow(Map.Entry snapshot) { Tag tag = snapshot.getValue(); - List branches = tagBranches.get(snapshot.getKey()); return GenericRow.of( BinaryString.fromString(snapshot.getKey()), tag.id(), tag.schemaId(), Timestamp.fromLocalDateTime(DateTimeUtils.toLocalDateTime(tag.timeMillis())), tag.totalRecordCount(), - BinaryString.fromString(branches == null ? "[]" : branches.toString()), Optional.ofNullable(tag.getTagCreateTime()) .map(Timestamp::fromLocalDateTime) .orElse(null), diff --git a/paimon-core/src/test/java/org/apache/paimon/table/system/TagsTableTest.java b/paimon-core/src/test/java/org/apache/paimon/table/system/TagsTableTest.java index a1b7770c5ec3..99c38df01503 100644 --- a/paimon-core/src/test/java/org/apache/paimon/table/system/TagsTableTest.java +++ b/paimon-core/src/test/java/org/apache/paimon/table/system/TagsTableTest.java @@ -26,7 +26,6 @@ import org.apache.paimon.manifest.ManifestCommittable; import org.apache.paimon.schema.Schema; import org.apache.paimon.table.FileStoreTable; -import org.apache.paimon.table.Table; import org.apache.paimon.table.TableTestBase; import org.apache.paimon.table.sink.TableCommitImpl; import org.apache.paimon.tag.Tag; @@ -40,10 +39,7 @@ import java.time.LocalDateTime; import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; import java.util.List; -import java.util.function.Function; import static org.assertj.core.api.Assertions.assertThat; @@ -87,38 +83,12 @@ void before() throws Exception { @Test void testTagsTable() throws Exception { - List expectRow = - getExceptedResult( - key -> { - return new ArrayList<>(); - }); + List expectRow = getExceptedResult(); List result = read(tagsTable); assertThat(result).containsExactlyElementsOf(expectRow); } - @Test - void testTagBranchesTable() throws Exception { - Table table = catalog.getTable(identifier(tableName)); - table.createBranch("2023-07-17-branch1", "2023-07-17"); - table.createBranch("2023-07-18-branch1", "2023-07-18"); - table.createBranch("2023-07-18-branch2", "2023-07-18"); - List expectRow = - getExceptedResult( - tag -> { - if (tag.equals("2023-07-17")) { - return Collections.singletonList("2023-07-17-branch1"); - } else if (tag.equals("2023-07-18")) { - return Arrays.asList("2023-07-18-branch1", "2023-07-18-branch2"); - } else { - return new ArrayList<>(); - } - }); - List result = read(tagsTable); - assertThat(result).containsExactlyElementsOf(expectRow); - } - - private List getExceptedResult( - Function> tagBranchesFunction) { + private List getExceptedResult() { List internalRows = new ArrayList<>(); for (Pair snapshot : tagManager.tagObjects()) { Tag tag = snapshot.getKey(); @@ -131,7 +101,6 @@ private List getExceptedResult( Timestamp.fromLocalDateTime( DateTimeUtils.toLocalDateTime(tag.timeMillis())), tag.totalRecordCount(), - BinaryString.fromString(tagBranchesFunction.apply(tagName).toString()), tag.getTagCreateTime() == null ? null : Timestamp.fromLocalDateTime(tag.getTagCreateTime()),