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/incubator-paimon.git
The following commit(s) were added to refs/heads/master by this push:
new bb836edea [core] Add database name and table name in BucketsTable
(#1915)
bb836edea is described below
commit bb836edea28a079ed544b1d9ed2f9324ad407bcf
Author: LsomeYeah <[email protected]>
AuthorDate: Wed Aug 30 18:18:41 2023 +0800
[core] Add database name and table name in BucketsTable (#1915)
---
.../org/apache/paimon/table/system/BucketsTable.java | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git
a/paimon-core/src/main/java/org/apache/paimon/table/system/BucketsTable.java
b/paimon-core/src/main/java/org/apache/paimon/table/system/BucketsTable.java
index 31f2665af..79712aa17 100644
--- a/paimon-core/src/main/java/org/apache/paimon/table/system/BucketsTable.java
+++ b/paimon-core/src/main/java/org/apache/paimon/table/system/BucketsTable.java
@@ -19,6 +19,7 @@
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;
import org.apache.paimon.disk.IOManager;
@@ -42,10 +43,13 @@ import org.apache.paimon.types.BigIntType;
import org.apache.paimon.types.DataField;
import org.apache.paimon.types.IntType;
import org.apache.paimon.types.RowType;
+import org.apache.paimon.types.VarCharType;
import org.apache.paimon.utils.IteratorRecordReader;
import org.apache.paimon.utils.SnapshotManager;
import org.apache.paimon.utils.TagManager;
+import javax.annotation.Nullable;
+
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
@@ -67,9 +71,17 @@ public class BucketsTable implements DataTable,
ReadonlyTable {
private final FileStoreTable wrapped;
private final boolean isContinuous;
+ @Nullable private final String databaseName;
+
public BucketsTable(FileStoreTable wrapped, boolean isContinuous) {
+ this(wrapped, isContinuous, null);
+ }
+
+ // if need to specify the database of a table, use this method
+ public BucketsTable(FileStoreTable wrapped, boolean isContinuous, String
databaseName) {
this.wrapped = wrapped;
this.isContinuous = isContinuous;
+ this.databaseName = databaseName;
}
@Override
@@ -99,6 +111,8 @@ public class BucketsTable implements DataTable,
ReadonlyTable {
fields.add(new DataField(1, "_PARTITION", newBytesType(false)));
fields.add(new DataField(2, "_BUCKET", new IntType(false)));
fields.add(new DataField(3, "_FILES", newBytesType(false)));
+ fields.add(new DataField(4, "_DATABASE_NAME", new VarCharType(true,
Integer.MAX_VALUE)));
+ fields.add(new DataField(5, "_TABLE_NAME", new VarCharType(false,
Integer.MAX_VALUE)));
return new RowType(fields);
}
@@ -139,7 +153,7 @@ public class BucketsTable implements DataTable,
ReadonlyTable {
@Override
public BucketsTable copy(Map<String, String> dynamicOptions) {
- return new BucketsTable(wrapped.copy(dynamicOptions), isContinuous);
+ return new BucketsTable(wrapped.copy(dynamicOptions), isContinuous,
databaseName);
}
@Override
@@ -187,7 +201,9 @@ public class BucketsTable implements DataTable,
ReadonlyTable {
dataSplit.snapshotId(),
serializeBinaryRow(dataSplit.partition()),
dataSplit.bucket(),
- dataFileMetaSerializer.serializeList(files));
+ dataFileMetaSerializer.serializeList(files),
+ BinaryString.fromString(databaseName),
+ BinaryString.fromString(wrapped.name()));
return new
IteratorRecordReader<>(Collections.singletonList(row).iterator());
}