Skip to content

[SPARK-52837][CONNECT][PYTHON] Support TimeType literal in Connect #51515

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

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

dengziming
Copy link
Member

@dengziming dengziming commented Jul 16, 2025

What changes were proposed in this pull request?

This is the follow-up of #51462 to support TimeType literal in pyspark connect.

Why are the changes needed?

To align the Python Connect client with the Java/Scala Connect client.

Does this PR introduce any user-facing change?

Yes, we can use TimeType literal in several ways, for example, PySparkSession.sql("SELECT TIME '12:13:14'")
and pyspark.sql.connect.functions.lit(datetime.time(12, 13, 14)).

How was this patch tested?

  1. Add some local literal convert tests
  2. Add pyspark SQL tests

Was this patch authored or co-authored using generative AI tooling?

No

@dengziming dengziming changed the title wip [SPARK-52779][CONNECT][PYTHON] Support TimeType literal in Connect [SPARK-52779][CONNECT][PYTHON] Support TimeType literal in Connect Jul 17, 2025
@dengziming
Copy link
Member Author

Hello @zhengruifeng @MaxGekk @peter-toth , please take a look at this, we should also support time literals in Connect.

@zhengruifeng zhengruifeng requested a review from HyukjinKwon July 17, 2025 06:13
Copy link
Member

@MaxGekk MaxGekk left a comment

Choose a reason for hiding this comment

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

@dengziming Please, open new ticket specifically for the python client.

@dengziming dengziming changed the title [SPARK-52779][CONNECT][PYTHON] Support TimeType literal in Connect [SPARK-51162][CONNECT][PYTHON] Support TimeType literal in Connect Jul 17, 2025
@dengziming dengziming changed the title [SPARK-51162][CONNECT][PYTHON] Support TimeType literal in Connect [SPARK-52837][CONNECT][PYTHON] Support TimeType literal in Connect Jul 17, 2025
@dengziming
Copy link
Member Author

@MaxGekk I have created a separate ticket.

@@ -384,6 +385,33 @@ def fromInternal(self, v: int) -> datetime.date:
return datetime.date.fromordinal(v + self.EPOCH_ORDINAL)


class TimeType(AtomicType):
Copy link
Contributor

Choose a reason for hiding this comment

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

this PR actually add a new datatype in pyspark, not just python client.
It should work with both python client and pyspark classic.
We'd better also add test for pyspark classic.

Copy link
Contributor

@zhengruifeng zhengruifeng Jul 17, 2025

Choose a reason for hiding this comment

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

And I just notice that the class hierarchy is not consistent with the JVM side:

case class TimeType(precision: Int) extends AnyTimeType

We'd better make them the same, by also introducing the AnyTimeType in pyspark. If we need to touch other existing date time types, we can do it in a separate PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not very professional with PySpark, this will take some time, I changed it to WIP by now.

@dengziming dengziming marked this pull request as draft July 18, 2025 02:23
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