-
Notifications
You must be signed in to change notification settings - Fork 2.5k
[HUDI-2852] Table metadata returns empty for non-exist partition #4117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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); | ||
| return recordsByKeys.size() == 0 ? Option.empty() : recordsByKeys.get(0).getValue(); | ||
| } | ||
|
|
||
| protected List<Pair<String, Option<HoodieRecord<HoodieMetadataPayload>>>> getRecordsByKeys(List<String> keys, String partitionName) { | ||
|
|
@@ -131,6 +132,10 @@ protected List<Pair<String, Option<HoodieRecord<HoodieMetadataPayload>>>> getRec | |
| HoodieFileReader baseFileReader = readers.getKey(); | ||
| HoodieMetadataMergedLogRecordReader logRecordScanner = readers.getRight(); | ||
|
|
||
| if (baseFileReader == null && logRecordScanner == null) { | ||
| return Collections.emptyList(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldn't this return Collections.singletonList(Pair.of(key, Option.empty()))
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should not, the original code returns key based on the metadata data file content, but here we do not have any data file actually.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. agree. with @danny0405 . that should be for empty partitions say. |
||
| } | ||
|
|
||
| // local map to assist in merging with base file records | ||
| Map<String, Option<HoodieRecord<HoodieMetadataPayload>>> logRecords = readLogRecords(logRecordScanner, keys, timings); | ||
| List<Pair<String, Option<HoodieRecord<HoodieMetadataPayload>>>> result = readFromBaseAndMergeWithLogRecords( | ||
|
|
@@ -241,6 +246,10 @@ private Pair<HoodieFileReader, HoodieMetadataMergedLogRecordReader> openReadersI | |
| // 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); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. returns nulls always make me nervous. Can we make the return type |
||
| } | ||
| ValidationUtils.checkArgument(latestFileSlices.size() == 1, String.format("Invalid number of file slices: found=%d, required=%d", latestFileSlices.size(), 1)); | ||
| final FileSlice slice = latestFileSlices.get(HoodieTableMetadataUtil.mapRecordKeyToFileGroupIndex(key, latestFileSlices.size())); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we get an exception now? is that the behavior?