klaus-xiong commented on PR #35756:
URL: https://github.com/apache/spark/pull/35756#issuecomment-1195105080
>
` test("Timestamp type should be read and writen correctly") {
val zoneIdAndNames =
Seq((UTC, "UTC"), (PST, "PST"), (getZoneId("Asia/Shanghai"), "SH"))
zoneIdAndNames.foreach { case (zoneId, zoneName) =>
withDefaultTimeZone(zoneId) {
// In avro the date "0001-01-01 00:00:00" will be read as
"0002-01-01 00:00:00"
Seq("sequencefile", "textfile", "rcfile", "orc", "avro").foreach {
format =>
val tableName = "t_timestamp_" + format + "_" + zoneName
withTable(tableName) {
sql(s"CREATE TABLE $tableName(a TIMESTAMP) STORED AS $format")
val timestamps = Seq(
"1000-01-01 00:00:00.123",
"1582-10-15 08:00:00.456",
"1883-11-18 19:59:59.999",
"1883-11-18 20:00:00.001",
"1900-11-18 20:00:00.789",
"1970-01-01 00:00:00")
val tsValues = timestamps.map(ts =>
s"(TIMESTAMP('$ts'))").mkString(",")
sql(s"INSERT INTO $tableName VALUES $tsValues")
val df = sql(
s"""
|SELECT
|CAST(a AS STRING) AS a
|FROM $tableName
|ORDER BY a
""".stripMargin)
checkAnswer(df, timestamps.toDF("a"))
}
}
}
}
}`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]