Skip to content
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

Make partitioned parquet reading deterministic #4739

Conversation

devinrsmith
Copy link
Member

@devinrsmith devinrsmith commented Oct 29, 2023

This ensures that the firstEntryPath is the lexicographically first entry.

Part of #4738

This ensures that the firstEntryPath is the lexicographically first entry.

Fixes deephaven#4738
@devinrsmith devinrsmith added bug Something isn't working parquet Related to the Parquet integration NoDocumentationNeeded NoReleaseNotesNeeded No release notes are needed. labels Oct 29, 2023
@devinrsmith devinrsmith added this to the October 2023 milestone Oct 29, 2023
@devinrsmith devinrsmith self-assigned this Oct 29, 2023
@@ -571,11 +572,13 @@ private static Table readTableInternal(
}
final Path firstEntryPath;
try (final DirectoryStream<Path> sourceStream = Files.newDirectoryStream(sourcePath)) {
final Iterator<Path> entryIterator = sourceStream.iterator();
if (!entryIterator.hasNext()) {
// Lexicographical comparison
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two things to raise here:

  1. @malhotrashivam take note, this may be a conflict with your PR
  2. @devinrsmith / @malhotrashivam I think we might prefer to take the max, instead of the min. If we think lexicographic order matters, it's often the case that there is a sortable timestamp (e.g. YYYY-MM-DD-blah) in the name. Taking the most recent gives us a better guess at the intended schema.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, the actual inference step is separate from this outer layer (readPartitionedTableInferSchema). My goal here was to make the existing behavior more deterministic; in this case, I think taking the min entry more closely matches the intentions and probable behavior of the existing code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't make anything more deterministic, unless you read the DirectoryStream JavaDocs with no context. Directories have an order on every file system I'm aware of.

@devinrsmith
Copy link
Member Author

I'm actually doubting my change is complete looking back at it - it is only setting us up deterministically for ParquetKeyValuePartitionedLayout vs ParquetFlatPartitionedLayout, but not how those work internally. I'm going to take another pass at this soon.

@devinrsmith
Copy link
Member Author

I think there is still value in merging this PR to make things more deterministic, but it doesn't actually fix the inference step. Will leave that for later.

@malhotrashivam
Copy link
Contributor

I think the change does what's it supposed to do. Do you think we should add a tiny test for this?

@devinrsmith
Copy link
Member Author

Closed in favor of more deterministic inference in #4783

@devinrsmith devinrsmith closed this Nov 7, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Nov 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working NoDocumentationNeeded NoReleaseNotesNeeded No release notes are needed. parquet Related to the Parquet integration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants