-
Notifications
You must be signed in to change notification settings - Fork 466
PR #1169 #1206
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
Closed
Closed
PR #1169 #1206
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2c52bf9
Add ns TimeType
JE-Chen b3e83cf
Remove ns raise TypeError test, because it will no longer raise a Typ…
JE-Chen ee3cd59
Revert "Remove ns raise TypeError test, because it will no longer rai…
JE-Chen a031c0d
Add downcast condition on Time64Type
JE-Chen 37c8198
Return TImeType not raise error here
JE-Chen 2c92638
ruff reformat
JE-Chen 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 hidden or 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 |
|---|---|---|
|
|
@@ -1068,20 +1068,13 @@ def primitive(self, primitive: pa.DataType) -> PrimitiveType: | |
| return StringType() | ||
| elif pa.types.is_date32(primitive): | ||
| return DateType() | ||
| elif isinstance(primitive, pa.Time64Type) and primitive.unit == "us": | ||
| elif isinstance(primitive, pa.Time64Type) and primitive.unit in ["us", "ns"]: | ||
| return TimeType() | ||
| elif pa.types.is_timestamp(primitive): | ||
| primitive = cast(pa.TimestampType, primitive) | ||
| if primitive.unit in ("s", "ms", "us"): | ||
| if primitive.unit in ("s", "ms", "us", "ns"): | ||
| # Supported types, will be upcast automatically to 'us' | ||
| pass | ||
| elif primitive.unit == "ns": | ||
| if self._downcast_ns_timestamp_to_us: | ||
| logger.warning("Iceberg does not yet support 'ns' timestamp precision. Downcasting to 'us'.") | ||
| else: | ||
| raise TypeError( | ||
| "Iceberg does not yet support 'ns' timestamp precision. Use 'downcast-ns-timestamp-to-us-on-write' configuration property to automatically downcast 'ns' to 'us' on write." | ||
| ) | ||
|
Comment on lines
-1078
to
-1084
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. this is still necessary because iceberg doesnt support
Contributor
Author
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 will add back this code snippet. |
||
| else: | ||
| raise TypeError(f"Unsupported precision for timestamp type: {primitive.unit}") | ||
|
|
||
|
|
||
This file contains hidden or 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
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.
dont need to check for precision here, since its
usandnsare supported.Although we need to add code to downcast
nstous, similar to belowThere 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.
Thank you for your response, but could you explain it more clearly?
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.
Time64Type only supports
usandns, so the extra check forprimitive.unit in ["us", "ns"]is redundant. Although, it'll be helpful if another precision was added in the future.Because Iceberg doesn't support
ns, it has to downcastnstous, or errors.This behavior is controlled by https://github.com/apache/iceberg-python/pull/1206/files#diff-8d5e63f2a87ead8cebe2fd8ac5dcf2198d229f01e16bb9e06e21f7277c328abdL1078-L1084
Which we also need to include here
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.
Like 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.
yep, do the same for
Time64TypeThere 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.
the
_downcast_ns_timestamp_to_uspart for sure. Im not sure if we need to docastthoughUh oh!
There was an error while loading. Please reload this page.
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.
Thank you for your response, But I am confused.
Did you mean that I need a new class variable _downcast_ns_time64type_to_us and a new condition to check?
Or should I add some code under the original condition:
Uh oh!
There was an error while loading. Please reload this page.
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.
So this function is converting pyarrow types to Iceberg types.
In the example of timestamp type (
pa.types.is_timestamp(primitive)), we check if theunit(or precision) isns. If it is and thedowncast-ns-timestamp-to-us-on-writeis set, we want to downcast theunitfromnstous. Ifdowncast-ns-timestamp-to-us-on-writeis not set, raise an error becausensis not supported.If its not, we don't do anything special and just return the Iceberg type.
We want to do the same thing with the
Time64Typetype.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.
essentially check if the
unitisns. if it is, checkdowncast-ns-timestamp-to-us-on-write. if the option is set, we can downcast fromnstous.If its not, raise an error
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.
Please check the new commit. Thanks.