Skip to content

Commit 1d400e5

Browse files
committed
1 parent 1ef11c6 commit 1d400e5

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

fe/fe-core/src/main/java/com/starrocks/catalog/PaimonTable.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
package com.starrocks.catalog;
1616

17+
import com.google.common.base.Strings;
1718
import com.starrocks.analysis.DescriptorTable;
1819
import com.starrocks.common.util.TimeUtils;
1920
import com.starrocks.planner.PaimonScanNode;
@@ -39,6 +40,7 @@ public class PaimonTable extends Table {
3940
private String databaseName;
4041
private String tableName;
4142
private org.apache.paimon.table.Table paimonNativeTable;
43+
private String uuid;
4244
private List<String> partColumnNames;
4345
private List<String> paimonFieldNames;
4446
private Map<String, String> properties;
@@ -86,7 +88,11 @@ public void setPaimonNativeTable(org.apache.paimon.table.Table paimonNativeTable
8688

8789
@Override
8890
public String getUUID() {
89-
return String.join(".", catalogName, databaseName, tableName, paimonNativeTable.uuid());
91+
if (Strings.isNullOrEmpty(this.uuid)) {
92+
this.uuid = String.join(".", catalogName, databaseName, tableName,
93+
paimonNativeTable.uuid().replace(".", "_"));
94+
}
95+
return this.uuid;
9096
}
9197

9298
@Override

fe/fe-core/src/main/java/com/starrocks/connector/paimon/PaimonMetadata.java

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public class PaimonMetadata implements ConnectorMetadata {
104104
private final Map<String, Database> databases = new ConcurrentHashMap<>();
105105
private final Map<PredicateSearchKey, PaimonSplitsInfo> paimonSplits = new ConcurrentHashMap<>();
106106
private final ConnectorProperties properties;
107-
private final Map<String, Partition> partitionInfos = new ConcurrentHashMap<>();
107+
private final Map<Identifier, Map<String, Partition>> partitionInfos = new ConcurrentHashMap<>();
108108

109109
public PaimonMetadata(String catalogName, HdfsEnvironment hdfsEnvironment, Catalog paimonNativeCatalog,
110110
ConnectorProperties properties) {
@@ -137,6 +137,9 @@ private void updatePartitionInfo(String databaseName, String tableName) {
137137
Identifier identifier = new Identifier(databaseName, tableName);
138138
org.apache.paimon.table.Table paimonTable;
139139
RowType dataTableRowType;
140+
if (!this.partitionInfos.containsKey(identifier)) {
141+
this.partitionInfos.put(identifier, new ConcurrentHashMap<>());
142+
}
140143
try {
141144
paimonTable = this.paimonNativeCatalog.getTable(identifier);
142145
dataTableRowType = paimonTable.rowType();
@@ -164,7 +167,7 @@ private void updatePartitionInfo(String databaseName, String tableName) {
164167
partition.fileSizeInBytes(), partition.fileCount(),
165168
partitionColumnNames, partitionColumnTypes, partitionValues,
166169
Timestamp.fromEpochMillis(partition.lastFileCreationTime()));
167-
this.partitionInfos.put(srPartition.getPartitionName(), srPartition);
170+
this.partitionInfos.get(identifier).put(srPartition.getPartitionName(), srPartition);
168171
}
169172
} catch (Catalog.TableNotExistException e) {
170173
LOG.error("Failed to update partition info of paimon table {}.{}.", databaseName, tableName, e);
@@ -210,8 +213,12 @@ private Long convertToSystemDefaultTime(Timestamp lastUpdateTime) {
210213

211214
@Override
212215
public List<String> listPartitionNames(String databaseName, String tableName, ConnectorMetadatRequestContext requestContext) {
216+
Identifier identifier = new Identifier(databaseName, tableName);
213217
updatePartitionInfo(databaseName, tableName);
214-
return new ArrayList<>(this.partitionInfos.keySet());
218+
if (this.partitionInfos.get(identifier) == null) {
219+
return Lists.newArrayList();
220+
}
221+
return new ArrayList<>(this.partitionInfos.get(identifier).keySet());
215222
}
216223

217224
@Override
@@ -277,6 +284,7 @@ public boolean tableExists(ConnectContext context, String dbName, String tableNa
277284
public List<RemoteFileInfo> getRemoteFiles(Table table, GetRemoteFilesParams params) {
278285
RemoteFileInfo remoteFileInfo = new RemoteFileInfo();
279286
PaimonTable paimonTable = (PaimonTable) table;
287+
Identifier identifier = new Identifier(paimonTable.getCatalogDBName(), paimonTable.getCatalogTableName());
280288
Optional<Snapshot> latestSnapshotOptional = paimonTable.getNativeTable().latestSnapshot();
281289
long latestSnapshotId = -1L;
282290
try {
@@ -553,6 +561,7 @@ public long getTableUpdateTime(String dbName, String tblName) {
553561
@Override
554562
public List<PartitionInfo> getPartitions(Table table, List<String> partitionNames) {
555563
PaimonTable paimonTable = (PaimonTable) table;
564+
Identifier identifier = new Identifier(paimonTable.getCatalogDBName(), paimonTable.getCatalogTableName());
556565
List<PartitionInfo> result = new ArrayList<>();
557566
if (table.isUnPartitioned()) {
558567

@@ -561,12 +570,13 @@ public List<PartitionInfo> getPartitions(Table table, List<String> partitionName
561570
null, null));
562571
return result;
563572
}
573+
Map<String, Partition> partitionInfo = this.partitionInfos.get(identifier);
564574
for (String partitionName : partitionNames) {
565-
if (this.partitionInfos.get(partitionName) == null) {
575+
if (partitionInfo == null || partitionInfo.get(partitionName) == null) {
566576
this.updatePartitionInfo(paimonTable.getCatalogDBName(), paimonTable.getCatalogTableName());
567577
}
568-
if (this.partitionInfos.get(partitionName) != null) {
569-
result.add(this.partitionInfos.get(partitionName));
578+
if (partitionInfo.get(partitionName) != null) {
579+
result.add(partitionInfo.get(partitionName));
570580
} else {
571581
LOG.warn("Cannot find the paimon partition info: {}", partitionName);
572582
}

0 commit comments

Comments
 (0)