-
Notifications
You must be signed in to change notification settings - Fork 81
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
feat: DH-18399: Add ParquetColumnResolver #6558
Merged
devinrsmith
merged 12 commits into
deephaven:main
from
devinrsmith:DH-18399-parquet-column-resolver
Jan 22, 2025
Merged
Changes from 2 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
d379760
feat: DH-18399: Add ParquetColumnResolver
devinrsmith ae60022
Fix test location
devinrsmith 554ada6
add tests, refactor
devinrsmith 964b2b6
small generalization
devinrsmith de1ad29
Merge remote-tracking branch 'upstream/main' into DH-18399-parquet-co…
devinrsmith 59b467f
documentation and testing
devinrsmith 67be4a0
f
devinrsmith c4b42b4
fix failure
devinrsmith e1f6cb0
small rename, refactor
devinrsmith 4433acd
Make ParquetSchemaUtil an internal library
devinrsmith aff378d
responses
devinrsmith 898514b
responses
devinrsmith File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
...uet/table/src/main/java/io/deephaven/parquet/table/location/ParquetColumnResolverMap.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// | ||
// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending | ||
// | ||
package io.deephaven.parquet.table.location; | ||
|
||
import io.deephaven.annotations.BuildableStyle; | ||
import org.apache.parquet.column.ColumnDescriptor; | ||
import org.apache.parquet.schema.MessageType; | ||
import org.immutables.value.Value; | ||
|
||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
/** | ||
* A {@link ParquetColumnResolver} implementation based on a map from Deephaven column names to Parquet | ||
* {@link ColumnDescriptor column descriptors}. | ||
*/ | ||
@Value.Immutable | ||
@BuildableStyle | ||
public abstract class ParquetColumnResolverMap implements ParquetColumnResolver { | ||
|
||
public static Builder builder() { | ||
return ImmutableParquetColumnResolverMap.builder(); | ||
} | ||
|
||
/** | ||
* The Parquet schema. | ||
*/ | ||
public abstract MessageType schema(); | ||
|
||
/** | ||
* The map from Deephaven column name to {@link ColumnDescriptor}. The {@link #schema()} must contain each column | ||
* descriptor. | ||
*/ | ||
public abstract Map<String, ColumnDescriptor> mapping(); | ||
|
||
@Override | ||
public final Optional<String[]> of(String columnName) { | ||
return Optional.ofNullable(mapping().get(columnName)).map(ColumnDescriptor::getPath); | ||
} | ||
|
||
public interface Builder { | ||
Builder schema(MessageType schema); | ||
|
||
Builder putMapping(String key, ColumnDescriptor value); | ||
|
||
Builder putAllMapping(Map<String, ? extends ColumnDescriptor> entries); | ||
|
||
ParquetColumnResolverMap build(); | ||
} | ||
|
||
@Value.Check | ||
final void checkMapping() { | ||
for (Map.Entry<String, ColumnDescriptor> e : mapping().entrySet()) { | ||
final ColumnDescriptor columnDescriptor = e.getValue(); | ||
if (!ParquetUtil.contains(schema(), columnDescriptor)) { | ||
throw new IllegalArgumentException( | ||
String.format("schema does not contain Deephaven columnName=%s columnDescriptor=%s", e.getKey(), | ||
columnDescriptor)); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Do we need this to keep
ColumnDescriptor
as part of the interface of the implementation? Do we want the Iceberg implementation using this?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.
I'm very much in favor of keeping this implementation strongly-typed with the safety checks. Iceberg should be able to use this implementation (and even use the same Factory to create it) in some situations.
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.
Changed my mind; the map implementation is now very generic, no Parquet specific types.