-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[SPARK-58766][PYTHON][TESTS] Represent out-of-range temporal PyArrow scalars in golden files #58000
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
Open
Spenserrrr
wants to merge
3
commits into
apache:master
Choose a base branch
from
Spenserrrr:golden-repr-out-of-range-temporal
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+196
−175
Open
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
2a226c5
[SPARK-58766][PYTHON][TESTS] Represent out-of-range temporal PyArrow …
Spenserrrr b86f25c
[SPARK-58766][PYTHON][TESTS] Use temporal[raw](value) for out-of-rang…
Spenserrrr 0a718f6
[SPARK-58766][PYTHON][TESTS] Render out-of-range temporal scalars as …
Spenserrrr 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
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
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.
Two questions:
rawdoes not read as a timestamp. maybe a format liketemporal[raw](xxxx)orraw-temporal=xxxxwould be better?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.
Thanks @Yicong-Huang!
(1) format: yeah
raw=is not clear. I updated it totemporal[raw](<value>)shape, so the cell now reads[temporal[raw](2147483647), temporal[raw](-2147483648), None]@date32[day]. The unit stays in the@date32[day]suffix.(2) Spark's date range: I checked the Scala side. In
sql/api/src/main/scala/org/apache/spark/sql/types/DateType.scala, the [0001-01-01, 9999-12-31] is a documented "valid range" in line 23-24, but it isn't actually enforced:sql/api/src/main/scala/org/apache/spark/sql/catalyst/util/SparkDateTimeUtils.scala,stringToDateparses up to 7-digit years, with the comment "An integer is able to represent a date within [+-]5 million years" in line 578The one place year 9999 matters is in
toPandas. When Spark passesdate_as_object=True, each date becomes a Pythondatetime.date, and this is hard-capped at year 9999. Withdate_as_object=Falseit wouldn't raise.So I agree that a year that large isn't a meaningful Spark date, but we need a rendering for this cell anyway because int32:max/min is a valid Arrow date32 and Python's str() can't render it correctly. Another way to make this explicit is that we can just drop the value and render it as when the date overflows. Please let me know if you have any other suggestions.
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 think we are monitoring arrow's behavior for pyspark/spark, so it is valid to say that we don't support year > 9999. maybe we can just render overflow?
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.
Yeah, that makes sense. I went with temporal overflow, and the cell now renders
[temporal overflow, temporal overflow, None]@date32[day].