You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/07/05 09:58:49 UTC
[GitHub] [spark] sarutak commented on a change in pull request #33210: [SPARK-35998][SQL] Make from_csv/to_csv to handle year-month intervals properly
sarutak commented on a change in pull request #33210:
URL: https://github.com/apache/spark/pull/33210#discussion_r663803202
##########
File path: sql/core/src/test/scala/org/apache/spark/sql/CsvFunctionsSuite.scala
##########
@@ -279,4 +281,31 @@ class CsvFunctionsSuite extends QueryTest with SharedSparkSession {
}
}
}
+
+ test("SPARK-35998: Make from_csv/to_csv to handle year-month intervals properly") {
+ val ymDF = Seq(Period.of(1, 2, 0)).toDF
+ Seq(
+ (YearMonthIntervalType(), "INTERVAL '1-2' YEAR TO MONTH", Period.of(1, 2, 0)),
+ (YearMonthIntervalType(YEAR), "INTERVAL '1' YEAR", Period.of(1, 0, 0)),
+ (YearMonthIntervalType(MONTH), "INTERVAL '14' MONTH", Period.of(1, 2, 0))
+ ).foreach { case (toCsvDtype, toCsvExpected, fromCsvExpected) =>
+ val toCsvDF = ymDF.select(to_csv(struct($"value" cast toCsvDtype)) as "csv")
+ checkAnswer(toCsvDF, Row(toCsvExpected))
+
+ DataTypeTestUtils.yearMonthIntervalTypes.foreach { fromCsvDtype =>
+ val fromJsonDF = toCsvDF
Review comment:
How embarrassing... Thanks.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org