Skip to content

Commit

Permalink
Add a test.
Browse files Browse the repository at this point in the history
  • Loading branch information
ueshin committed Feb 10, 2018
1 parent 939ac58 commit e20e9fd
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions python/pyspark/sql/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2867,6 +2867,35 @@ def test_create_dataframe_required_pandas_not_found(self):
"d": [pd.Timestamp.now().date()]})
self.spark.createDataFrame(pdf)

# Regression test for SPARK-23360
@unittest.skipIf(not _have_pandas, _pandas_requirement_message)
def test_create_dateframe_from_pandas_with_dst(self):
import pandas as pd
from datetime import datetime

pdf = pd.DataFrame({'time': [datetime(2015, 10, 31, 22, 30)]})

df = self.spark.createDataFrame(pdf)
self.assertPandasEqual(pdf, df.toPandas())

orig_env_tz = os.environ.get('TZ', None)
orig_session_tz = self.spark.conf.get('spark.sql.session.timeZone')
try:
tz = 'America/Los_Angeles'
os.environ['TZ'] = tz
time.tzset()
self.spark.conf.set('spark.sql.session.timeZone', tz)

df = self.spark.createDataFrame(pdf)
df.show()
self.assertPandasEqual(pdf, df.toPandas())
finally:
del os.environ['TZ']
if orig_env_tz is not None:
os.environ['TZ'] = orig_env_tz
time.tzset()
self.spark.conf.set('spark.sql.session.timeZone', orig_session_tz)


class HiveSparkSubmitTests(SparkSubmitTests):

Expand Down

0 comments on commit e20e9fd

Please sign in to comment.