HyukjinKwon opened a new pull request #33918: URL: https://github.com/apache/spark/pull/33918
### What changes were proposed in this pull request? This PR is a small followup of https://github.com/apache/spark/pull/33876 which proposes to use `datetime.tzinfo` instead of `datetime.tzname` to see if timezome information is provided or now. This way is consistent with other places such as: https://github.com/apache/spark/blob/9c5bcac61ee56fbb271e890cc33f9a983612c5b0/python/pyspark/sql/types.py#L182 https://github.com/apache/spark/blob/9c5bcac61ee56fbb271e890cc33f9a983612c5b0/python/pyspark/sql/types.py#L1662 ### Why are the changes needed? In some cases, `datetime.tzname` can raise an exception (https://docs.python.org/3/library/datetime.html#datetime.datetime.tzname): > ... raises an exception if the latter doesn’t return None or a string object, I was able to reproduce this in Jenkins with setting `spark.sql.timestampType` to `TIMESTAMP_NTZ` by default: ``` ====================================================================== ERROR: test_time_with_timezone (pyspark.sql.tests.test_serde.SerdeTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/jenkins/workspace/SparkPullRequestBuilder/python/pyspark/sql/tests/test_serde.py", line 92, in test_time_with_timezone ... File "/usr/lib/pypy3/lib-python/3/datetime.py", line 979, in tzname raise NotImplementedError("tzinfo subclass must override tzname()") NotImplementedError: tzinfo subclass must override tzname() ``` ### Does this PR introduce _any_ user-facing change? No to end users because it has not be released. This is rather a safeguard to prevent potential breakage. ### How was this patch tested? Manually tested. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
