diff options
-rw-r--r-- | python/pyspark/sql/tests.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/python/pyspark/sql/tests.py b/python/pyspark/sql/tests.py index 4d7cad5a1a..ed903334be 100644 --- a/python/pyspark/sql/tests.py +++ b/python/pyspark/sql/tests.py @@ -705,11 +705,12 @@ class SQLTests(ReusedPySparkTestCase): def test_time_with_timezone(self): day = datetime.date.today() now = datetime.datetime.now() - ts = time.mktime(now.timetuple()) + now.microsecond / 1e6 + ts = time.mktime(now.timetuple()) # class in __main__ is not serializable from pyspark.sql.tests import UTC utc = UTC() - utcnow = datetime.datetime.fromtimestamp(ts, utc) + utcnow = datetime.datetime.utcfromtimestamp(ts) # without microseconds + utcnow = datetime.datetime(*(utcnow.timetuple()[:6] + (now.microsecond, utc))) df = self.sqlCtx.createDataFrame([(day, now, utcnow)]) day1, now1, utcnow1 = df.first() self.assertEqual(day1, day) |