You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@paimon.apache.org by "FangYongs (via GitHub)" <gi...@apache.org> on 2024/01/22 08:20:32 UTC
[PR] [core][branch] Add branches system table [incubator-paimon]
FangYongs opened a new pull request, #2759:
URL: https://github.com/apache/incubator-paimon/pull/2759
<!-- Please specify the module before the PR name: [core] ... or [flink] ... -->
### Purpose
<!-- Linking this pull request to the issue -->
Linked issue: close #2758
Add system table for branches
### Tests
Added BranchesTableTest
### API and Format
no
### Documentation
no
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [core][branch] Add branches system table [incubator-paimon]
Posted by "FangYongs (via GitHub)" <gi...@apache.org>.
FangYongs commented on code in PR #2759:
URL: https://github.com/apache/incubator-paimon/pull/2759#discussion_r1493971664
##########
paimon-core/src/main/java/org/apache/paimon/branch/TableBranch.java:
##########
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.paimon.branch;
+
+import org.apache.paimon.Snapshot;
+
+/** {@link TableBranch} has branch relevant information for table. */
+public class TableBranch {
+ private final String branchName;
+ private final String tagName;
+ private final Snapshot snapshot;
Review Comment:
Rename the fields `tagName` and `snapshot`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [core][branch] Add branches system table [incubator-paimon]
Posted by "FangYongs (via GitHub)" <gi...@apache.org>.
FangYongs merged PR #2759:
URL: https://github.com/apache/incubator-paimon/pull/2759
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [core][branch] Add branches system table [incubator-paimon]
Posted by "FangYongs (via GitHub)" <gi...@apache.org>.
FangYongs commented on code in PR #2759:
URL: https://github.com/apache/incubator-paimon/pull/2759#discussion_r1469143585
##########
paimon-core/src/main/java/org/apache/paimon/utils/BranchManager.java:
##########
@@ -133,4 +141,43 @@ public boolean branchExists(String branchName) {
Path branchPath = branchPath(branchName);
return fileExists(branchPath);
}
+
+ /** Get branch count for the table. */
+ public long branchCount() {
+ try {
+ return listVersionedFileStatus(fileIO, branchDirectory(), BRANCH_PREFIX).count();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /** Get all branches for the table. */
+ public List<TableBranch> branches() {
+ try {
+ List<Pair<Path, Long>> paths =
+ listVersionedFileStatus(fileIO, branchDirectory(), BRANCH_PREFIX)
+ .map(status -> Pair.of(status.getPath(), status.getModificationTime()))
+ .collect(Collectors.toList());
+ List<TableBranch> branches = new ArrayList<>();
+ for (Pair<Path, Long> path : paths) {
+ String branchName = path.getLeft().getName().substring(BRANCH_PREFIX.length());
+ FileStoreTable branchTable =
+ FileStoreTableFactory.create(
+ fileIO, new Path(getBranchPath(tablePath, branchName)));
+ Snapshot snapshot = branchTable.snapshotManager().latestSnapshot();
Review Comment:
@TaoZex `FileStoreTableFactory` will create table from branch path and the `branchTable.snapshotManager().latestSnapshot()` will return the latest snapshot in the specified branch
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [core][branch] Add branches system table [incubator-paimon]
Posted by "schnappi17 (via GitHub)" <gi...@apache.org>.
schnappi17 commented on code in PR #2759:
URL: https://github.com/apache/incubator-paimon/pull/2759#discussion_r1475473794
##########
paimon-core/src/main/java/org/apache/paimon/utils/BranchManager.java:
##########
@@ -133,4 +141,43 @@ public boolean branchExists(String branchName) {
Path branchPath = branchPath(branchName);
return fileExists(branchPath);
}
+
+ /** Get branch count for the table. */
+ public long branchCount() {
+ try {
+ return listVersionedFileStatus(fileIO, branchDirectory(), BRANCH_PREFIX).count();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /** Get all branches for the table. */
+ public List<TableBranch> branches() {
Review Comment:
I see this in this pr https://github.com/apache/incubator-paimon/pull/2754 and return different types, they may conflict before merging.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [core][branch] Add branches system table [incubator-paimon]
Posted by "FangYongs (via GitHub)" <gi...@apache.org>.
FangYongs commented on code in PR #2759:
URL: https://github.com/apache/incubator-paimon/pull/2759#discussion_r1493971501
##########
paimon-core/src/main/java/org/apache/paimon/utils/BranchManager.java:
##########
@@ -133,4 +141,43 @@ public boolean branchExists(String branchName) {
Path branchPath = branchPath(branchName);
return fileExists(branchPath);
}
+
+ /** Get branch count for the table. */
+ public long branchCount() {
+ try {
+ return listVersionedFileStatus(fileIO, branchDirectory(), BRANCH_PREFIX).count();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /** Get all branches for the table. */
+ public List<TableBranch> branches() {
Review Comment:
Fixed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [core][branch] Add branches system table [incubator-paimon]
Posted by "schnappi17 (via GitHub)" <gi...@apache.org>.
schnappi17 commented on code in PR #2759:
URL: https://github.com/apache/incubator-paimon/pull/2759#discussion_r1475478570
##########
paimon-core/src/main/java/org/apache/paimon/table/system/BranchesTable.java:
##########
@@ -0,0 +1,221 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.paimon.table.system;
+
+import org.apache.paimon.Snapshot;
+import org.apache.paimon.branch.TableBranch;
+import org.apache.paimon.data.BinaryString;
+import org.apache.paimon.data.GenericRow;
+import org.apache.paimon.data.InternalRow;
+import org.apache.paimon.data.Timestamp;
+import org.apache.paimon.disk.IOManager;
+import org.apache.paimon.fs.FileIO;
+import org.apache.paimon.fs.Path;
+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;
+import org.apache.paimon.table.source.InnerTableScan;
+import org.apache.paimon.table.source.ReadOnceTableScan;
+import org.apache.paimon.table.source.Split;
+import org.apache.paimon.table.source.TableRead;
+import org.apache.paimon.types.BigIntType;
+import org.apache.paimon.types.DataField;
+import org.apache.paimon.types.RowType;
+import org.apache.paimon.types.TimestampType;
+import org.apache.paimon.utils.DateTimeUtils;
+import org.apache.paimon.utils.IteratorRecordReader;
+import org.apache.paimon.utils.ProjectedRow;
+import org.apache.paimon.utils.SerializationUtils;
+
+import org.apache.paimon.shade.guava30.com.google.common.collect.Iterators;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+
+import static org.apache.paimon.catalog.Catalog.SYSTEM_TABLE_SPLITTER;
+
+/** A {@link Table} for showing branches of table. */
+public class BranchesTable implements ReadonlyTable {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final String BRANCHES = "branches";
+
+ public static final RowType TABLE_TYPE =
+ new RowType(
+ Arrays.asList(
+ new DataField(
+ 0, "branch_name", SerializationUtils.newStringType(false)),
+ new DataField(1, "tag_name", SerializationUtils.newStringType(false)),
+ new DataField(2, "latest_snapshot_id", new BigIntType(false)),
Review Comment:
So by design, we only show the LATEST snapshot, schema right? What if the branches system table store the series of snapshot and the snapshot info could be queried through join the snapshot system table, WDYT?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [core][branch] Add branches system table [incubator-paimon]
Posted by "schnappi17 (via GitHub)" <gi...@apache.org>.
schnappi17 commented on PR #2759:
URL: https://github.com/apache/incubator-paimon/pull/2759#issuecomment-1951761264
+1 for this
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [core][branch] Add branches system table [incubator-paimon]
Posted by "schnappi17 (via GitHub)" <gi...@apache.org>.
schnappi17 commented on code in PR #2759:
URL: https://github.com/apache/incubator-paimon/pull/2759#discussion_r1475475836
##########
paimon-core/src/main/java/org/apache/paimon/branch/TableBranch.java:
##########
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.paimon.branch;
+
+import org.apache.paimon.Snapshot;
+
+/** {@link TableBranch} has branch relevant information for table. */
+public class TableBranch {
+ private final String branchName;
+ private final String tagName;
+ private final Snapshot snapshot;
Review Comment:
I think branch should be a ref for a series snapshots, because we could write to a branch and generate new snapshots in the specific branch, what's this snapshot property here represents for?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [core][branch] Add branches system table [incubator-paimon]
Posted by "TaoZex (via GitHub)" <gi...@apache.org>.
TaoZex commented on code in PR #2759:
URL: https://github.com/apache/incubator-paimon/pull/2759#discussion_r1461806614
##########
paimon-core/src/main/java/org/apache/paimon/utils/BranchManager.java:
##########
@@ -133,4 +141,43 @@ public boolean branchExists(String branchName) {
Path branchPath = branchPath(branchName);
return fileExists(branchPath);
}
+
+ /** Get branch count for the table. */
+ public long branchCount() {
+ try {
+ return listVersionedFileStatus(fileIO, branchDirectory(), BRANCH_PREFIX).count();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /** Get all branches for the table. */
+ public List<TableBranch> branches() {
+ try {
+ List<Pair<Path, Long>> paths =
+ listVersionedFileStatus(fileIO, branchDirectory(), BRANCH_PREFIX)
+ .map(status -> Pair.of(status.getPath(), status.getModificationTime()))
+ .collect(Collectors.toList());
+ List<TableBranch> branches = new ArrayList<>();
+ for (Pair<Path, Long> path : paths) {
+ String branchName = path.getLeft().getName().substring(BRANCH_PREFIX.length());
+ FileStoreTable branchTable =
+ FileStoreTableFactory.create(
+ fileIO, new Path(getBranchPath(tablePath, branchName)));
+ Snapshot snapshot = branchTable.snapshotManager().latestSnapshot();
Review Comment:
`branchTable.snapshotManager().latestSnapshot()` will return lastest snapshot in main branch.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [core][branch] Add branches system table [incubator-paimon]
Posted by "FangYongs (via GitHub)" <gi...@apache.org>.
FangYongs commented on code in PR #2759:
URL: https://github.com/apache/incubator-paimon/pull/2759#discussion_r1493972121
##########
paimon-core/src/main/java/org/apache/paimon/table/system/BranchesTable.java:
##########
@@ -0,0 +1,221 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.paimon.table.system;
+
+import org.apache.paimon.Snapshot;
+import org.apache.paimon.branch.TableBranch;
+import org.apache.paimon.data.BinaryString;
+import org.apache.paimon.data.GenericRow;
+import org.apache.paimon.data.InternalRow;
+import org.apache.paimon.data.Timestamp;
+import org.apache.paimon.disk.IOManager;
+import org.apache.paimon.fs.FileIO;
+import org.apache.paimon.fs.Path;
+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;
+import org.apache.paimon.table.source.InnerTableScan;
+import org.apache.paimon.table.source.ReadOnceTableScan;
+import org.apache.paimon.table.source.Split;
+import org.apache.paimon.table.source.TableRead;
+import org.apache.paimon.types.BigIntType;
+import org.apache.paimon.types.DataField;
+import org.apache.paimon.types.RowType;
+import org.apache.paimon.types.TimestampType;
+import org.apache.paimon.utils.DateTimeUtils;
+import org.apache.paimon.utils.IteratorRecordReader;
+import org.apache.paimon.utils.ProjectedRow;
+import org.apache.paimon.utils.SerializationUtils;
+
+import org.apache.paimon.shade.guava30.com.google.common.collect.Iterators;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+
+import static org.apache.paimon.catalog.Catalog.SYSTEM_TABLE_SPLITTER;
+
+/** A {@link Table} for showing branches of table. */
+public class BranchesTable implements ReadonlyTable {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final String BRANCHES = "branches";
+
+ public static final RowType TABLE_TYPE =
+ new RowType(
+ Arrays.asList(
+ new DataField(
+ 0, "branch_name", SerializationUtils.newStringType(false)),
+ new DataField(1, "tag_name", SerializationUtils.newStringType(false)),
+ new DataField(2, "latest_snapshot_id", new BigIntType(false)),
Review Comment:
Rename the `tag_name` and `latest_snapshot_id` to `created_from_tag` and `created_from_snapshot` for the branche
##########
paimon-core/src/main/java/org/apache/paimon/table/system/BranchesTable.java:
##########
@@ -0,0 +1,221 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.paimon.table.system;
+
+import org.apache.paimon.Snapshot;
+import org.apache.paimon.branch.TableBranch;
+import org.apache.paimon.data.BinaryString;
+import org.apache.paimon.data.GenericRow;
+import org.apache.paimon.data.InternalRow;
+import org.apache.paimon.data.Timestamp;
+import org.apache.paimon.disk.IOManager;
+import org.apache.paimon.fs.FileIO;
+import org.apache.paimon.fs.Path;
+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;
+import org.apache.paimon.table.source.InnerTableScan;
+import org.apache.paimon.table.source.ReadOnceTableScan;
+import org.apache.paimon.table.source.Split;
+import org.apache.paimon.table.source.TableRead;
+import org.apache.paimon.types.BigIntType;
+import org.apache.paimon.types.DataField;
+import org.apache.paimon.types.RowType;
+import org.apache.paimon.types.TimestampType;
+import org.apache.paimon.utils.DateTimeUtils;
+import org.apache.paimon.utils.IteratorRecordReader;
+import org.apache.paimon.utils.ProjectedRow;
+import org.apache.paimon.utils.SerializationUtils;
+
+import org.apache.paimon.shade.guava30.com.google.common.collect.Iterators;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+
+import static org.apache.paimon.catalog.Catalog.SYSTEM_TABLE_SPLITTER;
+
+/** A {@link Table} for showing branches of table. */
+public class BranchesTable implements ReadonlyTable {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final String BRANCHES = "branches";
+
+ public static final RowType TABLE_TYPE =
+ new RowType(
+ Arrays.asList(
+ new DataField(
+ 0, "branch_name", SerializationUtils.newStringType(false)),
+ new DataField(1, "tag_name", SerializationUtils.newStringType(false)),
+ new DataField(2, "latest_snapshot_id", new BigIntType(false)),
Review Comment:
Rename the `tag_name` and `latest_snapshot_id` to `created_from_tag` and `created_from_snapshot` for the branch
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org