Skip to content

Conversation

@grundprinzip
Copy link
Contributor

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

@grundprinzip
Copy link
Contributor Author

@AmplabJenkins
Copy link

Can one of the admins verify this patch?

@grundprinzip
Copy link
Contributor Author

@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.")
Copy link
Member

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:
Copy link
Member

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))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@HyukjinKwon
Copy link
Member

Merged to master.

Let's address complete types in a followup.

SandishKumarHN pushed a commit to SandishKumarHN/spark that referenced this pull request Dec 12, 2022
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants