Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions python/pyspark/sql/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1435,6 +1435,14 @@ def test_time_with_timezone(self):
self.assertEqual(now, now1)
self.assertEqual(now, utcnow1)

# regression test for SPARK-19561
def test_datetime_at_epoch(self):
epoch = datetime.datetime.fromtimestamp(0)
df = self.spark.createDataFrame([Row(date=epoch)]).select('date', lit(epoch).alias('lit_date'))
first = df.first()
self.assertEqual(first['date'], epoch)
self.assertEqual(first['lit_date'], epoch)

def test_decimal(self):
from decimal import Decimal
schema = StructType([StructField("decimal", DecimalType(10, 5))])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ object EvaluatePython {
case (c: Int, DateType) => c

case (c: Long, TimestampType) => c
case (c: Int, TimestampType) => c.toLong
Copy link
Member

@viirya viirya Mar 9, 2017

Choose a reason for hiding this comment

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

Can you add a comment for the reason why we recognize Int as TimestampType too here?


case (c, StringType) => UTF8String.fromString(c.toString)

Expand Down