Skip to content

Commit 8cd9694

Browse files
author
mingfeng
committed
support real uuid for iceberg table
1 parent ccbfae1 commit 8cd9694

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

paimon-core/src/main/java/org/apache/paimon/catalog/CatalogUtils.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ public static Table loadTable(
264264
}
265265

266266
if (options.type() == TableType.ICEBERG_TABLE) {
267-
return toIcebergTable(identifier, schema, dataFileIO);
267+
return toIcebergTable(identifier, schema, dataFileIO, metadata.uuid());
268268
}
269269

270270
Identifier tableIdentifier = identifier;
@@ -443,7 +443,10 @@ private static LanceTable toLanceTable(
443443
}
444444

445445
private static IcebergTable toIcebergTable(
446-
Identifier identifier, TableSchema schema, Function<Path, FileIO> fileIO) {
446+
Identifier identifier,
447+
TableSchema schema,
448+
Function<Path, FileIO> fileIO,
449+
@Nullable String uuid) {
447450
Map<String, String> options = schema.options();
448451
String location = options.get(CoreOptions.PATH.key());
449452
return IcebergTable.builder()
@@ -454,6 +457,7 @@ private static IcebergTable toIcebergTable(
454457
.partitionKeys(schema.partitionKeys())
455458
.options(options)
456459
.comment(schema.comment())
460+
.uuid(uuid)
457461
.build();
458462
}
459463
}

paimon-core/src/main/java/org/apache/paimon/table/iceberg/IcebergTable.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class Builder {
5050
private String location;
5151
private Map<String, String> options;
5252
private String comment;
53+
private String uuid;
5354

5455
public Builder identifier(Identifier identifier) {
5556
this.identifier = identifier;
@@ -86,9 +87,14 @@ public Builder comment(String comment) {
8687
return this;
8788
}
8889

90+
public Builder uuid(String uuid) {
91+
this.uuid = uuid;
92+
return this;
93+
}
94+
8995
public IcebergTable build() {
9096
return new IcebergTableImpl(
91-
identifier, fileIO, rowType, partitionKeys, location, options, comment);
97+
identifier, fileIO, rowType, partitionKeys, location, options, comment, uuid);
9298
}
9399
}
94100
}

paimon-core/src/main/java/org/apache/paimon/table/iceberg/IcebergTableImpl.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.apache.paimon.table.source.InnerTableRead;
2626
import org.apache.paimon.table.source.InnerTableScan;
2727
import org.apache.paimon.types.RowType;
28+
import org.apache.paimon.utils.StringUtils;
2829

2930
import javax.annotation.Nullable;
3031

@@ -44,6 +45,7 @@ public class IcebergTableImpl implements ReadonlyTable, IcebergTable {
4445
private final String location;
4546
private final Map<String, String> options;
4647
@Nullable private final String comment;
48+
@Nullable private final String uuid;
4749

4850
public IcebergTableImpl(
4951
Identifier identifier,
@@ -52,14 +54,16 @@ public IcebergTableImpl(
5254
List<String> partitionKeys,
5355
String location,
5456
Map<String, String> options,
55-
@Nullable String comment) {
57+
@Nullable String comment,
58+
@Nullable String uuid) {
5659
this.identifier = identifier;
5760
this.fileIO = fileIO;
5861
this.rowType = rowType;
5962
this.partitionKeys = partitionKeys;
6063
this.location = location;
61-
this.options = options;
64+
this.options = options == null ? Collections.emptyMap() : options;
6265
this.comment = comment;
66+
this.uuid = uuid;
6367
}
6468

6569
@Override
@@ -72,6 +76,11 @@ public String fullName() {
7276
return identifier.getFullName();
7377
}
7478

79+
@Override
80+
public String uuid() {
81+
return StringUtils.isEmpty(uuid) ? fullName() : uuid;
82+
}
83+
7584
@Override
7685
public RowType rowType() {
7786
return rowType;
@@ -117,7 +126,7 @@ public IcebergTable copy(Map<String, String> dynamicOptions) {
117126
Map<String, String> newOptions = new HashMap<>(options);
118127
newOptions.putAll(dynamicOptions);
119128
return new IcebergTableImpl(
120-
identifier, fileIO, rowType, partitionKeys, location, newOptions, comment);
129+
identifier, fileIO, rowType, partitionKeys, location, newOptions, comment, uuid);
121130
}
122131

123132
@Override

0 commit comments

Comments
 (0)