MaxGekk commented on a change in pull request #33716:
URL: https://github.com/apache/spark/pull/33716#discussion_r688478146
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/IntervalUtils.scala
##########
@@ -181,8 +181,35 @@ object IntervalUtils {
"year-month", YM(startField, endField).typeName)
}
}
- case _ => throwIllegalIntervalFormatException(input, startField,
endField,
- "year-month", YM(startField, endField).typeName)
+ case _ =>
+ try {
+ val calendar = stringToInterval(input)
Review comment:
Why did you implement parsing of non-ANSI interval in the function which
is supposed to parse ANSI year-month interval strings?
##########
File path: sql/core/src/test/resources/sql-tests/results/cast.sql.out
##########
@@ -458,3 +458,59 @@ struct<CAST(
xyz
AS BOOLEAN):boolean>
-- !query output
NULL
+
+
+-- !query
+SELECT CAST('1 year 2 month' AS INTERVAL YEAR TO MONTH)
+-- !query schema
+struct<CAST(1 year 2 month AS INTERVAL YEAR TO MONTH):interval year to month>
+-- !query output
+1-2
+
+
+-- !query
+SELECT CAST('1 year 2 month 3 day' AS INTERVAL YEAR TO MONTH)
+-- !query schema
+struct<CAST(1 year 2 month 3 day AS INTERVAL YEAR TO MONTH):interval year to
month>
+-- !query output
+1-2
Review comment:
Not sure that we should support casting of mixed interval as ANSI
intervals. cc @cloud-fan
--
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]