-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-40533] [CONNECT] [PYTHON] Support most built-in literal types for Python in Spark Connect #38462
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
Conversation
|
Can one of the admins verify this patch? |
|
@HyukjinKwon removed the UUID support, please have another look. |
| exp.literal.decimal.scale = abs(v_tuple.exponent) | ||
| exp.literal.decimal.precision = len(v_tuple.digits) - abs(v_tuple.exponent) | ||
| # Two complement yeah... | ||
| raise ValueError("Python Decimal not supported.") |
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.
Can we remove if this is not implemented yet?
| # Days since epoch. | ||
| days_since_epoch = (cast(datetime.date, self._value) - datetime.date(1970, 1, 1)).days | ||
| exp.literal.date = days_since_epoch | ||
| elif value_type is uuid.UUID: |
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.
Maybe we could remove elif so else branch throw the exception?
| # Microseconds since epoch. | ||
| dt = cast(datetime.datetime, self._value) | ||
| v = dt - datetime.datetime(1970, 1, 1, 0, 0, 0, 0) | ||
| exp.literal.timestamp = int(v / datetime.timedelta(microseconds=1)) |
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.
Can we maybe match the implementation in PySpark's: https://github.com/apache/spark/blob/master/python/pyspark/sql/types.py#L254-L260 ?
|
Merged to master. Let's address complete types in a followup. |
…r Python in Spark Connect ### What changes were proposed in this pull request? This PR implements the client-side serialization of most Python literals into Spark Connect literals. ### Why are the changes needed? Expanding the Python client support. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? UT Closes apache#38462 from grundprinzip/SPARK-40533. Lead-authored-by: Martin Grund <[email protected]> Co-authored-by: Martin Grund <[email protected]> Signed-off-by: Hyukjin Kwon <[email protected]>
What changes were proposed in this pull request?
This PR implements the client-side serialization of most Python literals into Spark Connect literals.
Why are the changes needed?
Expanding the Python client support.
Does this PR introduce any user-facing change?
No
How was this patch tested?
UT