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
3 changes: 2 additions & 1 deletion sql/api/src/main/scala/org/apache/spark/sql/Row.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package org.apache.spark.sql

import java.sql.{Date, Timestamp}
import java.time.{Instant, LocalDate}
import java.time.{Instant, LocalDate, LocalDateTime}
import java.util.Base64

import scala.collection.mutable
Expand Down Expand Up @@ -627,6 +627,7 @@ trait Row extends Serializable {
case (d: Date, _) => JString(dateFormatter.format(d))
case (i: Instant, _) => JString(timestampFormatter.format(i))
case (t: Timestamp, _) => JString(timestampFormatter.format(t))
case (d: LocalDateTime, _) => JString(timestampFormatter.format(d))
case (i: CalendarInterval, _) => JString(i.toString)
case (a: Array[_], ArrayType(elementType, _)) =>
iteratorToJsonArray(a.iterator, elementType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package org.apache.spark.sql

import java.sql.{Date, Timestamp}
import java.time.LocalDate
import java.time.{LocalDate, LocalDateTime}

import org.json4s.JsonAST.{JArray, JBool, JDecimal, JDouble, JLong, JNull, JObject, JString, JValue}

Expand Down Expand Up @@ -84,6 +84,7 @@ class RowJsonSuite extends SparkFunSuite {
Timestamp.valueOf("2017-05-30 10:22:03.00").toInstant,
TimestampType,
JString("2017-05-30 10:22:03"))
testJson(LocalDateTime.of(2018, 5, 14, 12, 13), TimestampNTZType, JString("2018-05-14 12:13:00"))

// Complex types
testJson(
Expand Down