Skip to content

Commit

Permalink
[SPARK-47202][PYTHON] Fix typo breaking datetimes with tzinfo
Browse files Browse the repository at this point in the history
### What changes were proposed in this pull request?
This PR fixes a bug caused due to a typo.

### Why are the changes needed?
This bug is preventing users from having datetime.datetime objects with tzinfo when using the `TimestampType`

### Does this PR introduce _any_ user-facing change?
No, just a bug fix.

### How was this patch tested?
There ought to be CI that lints code and catches these simple errors at the time of opening the PR.

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

Closes apache#45301 from arzavj/SPARK-47202.

Authored-by: Arzav Jain <arzavj@users.noreply.github.com>
Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>
  • Loading branch information
arzavj authored and HyukjinKwon committed Feb 28, 2024
1 parent 6385cf1 commit bf8396e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion python/pyspark/sql/pandas/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ def convert_struct(value: Any) -> Any:

def convert_timestamp(value: Any) -> Any:
if isinstance(value, datetime.datetime) and value.tzinfo is not None:
ts = pd.Timstamp(value)
ts = pd.Timestamp(value)
else:
ts = pd.Timestamp(value).tz_localize(timezone)
return ts.to_pydatetime()
Expand Down

0 comments on commit bf8396e

Please sign in to comment.