vinothchandar commented on a change in pull request #4117:
URL: https://github.com/apache/hudi/pull/4117#discussion_r757215856



##########
File path: 
hudi-common/src/main/java/org/apache/hudi/metadata/HoodieBackedTableMetadata.java
##########
@@ -121,7 +121,8 @@ private void initIfNeeded() {
 
   @Override
   protected Option<HoodieRecord<HoodieMetadataPayload>> getRecordByKey(String 
key, String partitionName) {
-    return getRecordsByKeys(Collections.singletonList(key), 
partitionName).get(0).getValue();
+    List<Pair<String, Option<HoodieRecord<HoodieMetadataPayload>>>> 
recordsByKeys = getRecordsByKeys(Collections.singletonList(key), partitionName);

Review comment:
       we get an exception now? is that the behavior?

##########
File path: 
hudi-common/src/main/java/org/apache/hudi/metadata/HoodieBackedTableMetadata.java
##########
@@ -131,6 +132,10 @@ private void initIfNeeded() {
       HoodieFileReader baseFileReader = readers.getKey();
       HoodieMetadataMergedLogRecordReader logRecordScanner = 
readers.getRight();
 
+      if (baseFileReader == null && logRecordScanner == null) {
+        return Collections.emptyList();

Review comment:
       agree. with @danny0405 . that should be for empty partitions say. 

##########
File path: 
hudi-common/src/main/java/org/apache/hudi/metadata/HoodieBackedTableMetadata.java
##########
@@ -241,6 +246,10 @@ private void initIfNeeded() {
         // Metadata is in sync till the latest completed instant on the dataset
         HoodieTimer timer = new HoodieTimer().startTimer();
         List<FileSlice> latestFileSlices = 
HoodieTableMetadataUtil.loadPartitionFileGroupsWithLatestFileSlices(metadataMetaClient,
 partitionName);
+        if (latestFileSlices.size() == 0) {
+          // empty partition
+          return Pair.of(null, null);

Review comment:
       returns nulls always make me nervous. Can we make the return type 
`Option<Pair<>>`? and return empty?




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to