cloud-fan commented on a change in pull request #32940:
URL: https://github.com/apache/spark/pull/32940#discussion_r657266406
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/IntervalUtils.scala
##########
@@ -105,25 +105,62 @@ object IntervalUtils {
private val yearMonthRegex = (s"^$yearMonthPatternString$$").r
private val yearMonthLiteralRegex =
(s"(?i)^INTERVAL\\s+([+|-])?'$yearMonthPatternString'\\s+YEAR\\s+TO\\s+MONTH$$").r
+ private val yearMonthIndividualLiteralRegex =
+ (s"(?i)^INTERVAL\\s+([+|-])?'([+|-])?(\\d+)'\\s+(YEAR|MONTH)$$").r
+
+ private def getSign(firstSign: String, secondSign: String): Int = {
+ (firstSign, secondSign) match {
+ case ("-", "-") => 1
+ case ("-", _) => -1
+ case (_, "-") => -1
+ case (_, _) => 1
+ }
+ }
def castStringToYMInterval(
input: UTF8String,
- // TODO(SPARK-35768): Take into account year-month interval fields in
cast
startField: Byte,
endField: Byte): Int = {
+
+ val supportedFormat = Map(
+ (YM.YEAR, YM.MONTH) -> Seq("[+|-]y-m", "INTERVAL [+|-]'[+|-]y-m' YEAR TO
MONTH"),
+ (YM.YEAR, YM.YEAR) -> Seq("INTERVAL [+|-]'[+|-]y' YEAR"),
Review comment:
`cast('1' as interval year)` this works in pgsql
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]