BUG: IntervalDtype Arrow round-trip for tz-aware datetime subtypes - #66291
Open
ShashwatAgrawal20 wants to merge 2 commits into
Open
BUG: IntervalDtype Arrow round-trip for tz-aware datetime subtypes#66291ShashwatAgrawal20 wants to merge 2 commits into
ShashwatAgrawal20 wants to merge 2 commits into
Conversation
…H#64297) IntervalDtype.__from_arrow__ used np.asarray with the subtype, which fails for DatetimeTZDtype. Convert extension subtypes via __from_arrow__ instead, support tz intervals in IntervalArray.__arrow_array__, and deserialize ArrowIntervalType from the storage type so tz-aware timestamps work.
…onversion mypy rejected self._left._ndarray because bounds are typed as a union including ndarray; assert DatetimeArray for the DatetimeTZDtype path.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
IntervalDtype.__from_arrow__raises a TypeError when subtype is a nullable ExtensionDtype #64297doc/source/whatsnew/vX.Y.Z.rstfile if fixing a bug or adding a new feature.Problem description
IntervalDtype.__from_arrow__usednp.asarray(..., dtype=self.subtype), which raises for timezone-aware datetime subtypes:IntervalArray.__arrow_array__also failed for the same subtype viapyarrow.from_numpy_dtype, andArrowIntervalTypedeserialization could not reconstruct tz-aware timestamp subtypes withtype_for_alias.Solution
__from_arrow__when the subtype is an extension dtype (e.g.DatetimeTZDtype).IntervalArray.__arrow_array__to emit tz-aware timestamp fields forDatetimeTZDtypebounds.ArrowIntervalTypefrom the storage type's field type so tz-aware timestamps round-trip.