Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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)])
first = df.select('date', lit(epoch).alias('lit_date')).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,8 @@ object EvaluatePython {
case (c: Int, DateType) => c

case (c: Long, TimestampType) => c
// Py4J serializes values between MIN_INT and MAX_INT as Ints, not Longs
case (c: Int, TimestampType) => c.toLong

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

Expand Down