@@ -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