dongjoon-hyun commented on a change in pull request #26446: [SPARK-29393][SQL]
Add `make_interval` function
URL: https://github.com/apache/spark/pull/26446#discussion_r344468344
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/intervalExpressions.scala
##########
@@ -153,3 +153,106 @@ case class MultiplyInterval(interval: Expression, num:
Expression)
case class DivideInterval(interval: Expression, num: Expression)
extends IntervalNumOperation(interval, num, divide, "divide")
+
+// scalastyle:off line.size.limit
+@ExpressionDescription(
+ usage = "_FUNC_(years, months, weeks, days, hours, mins, secs) - Make
interval from years, months, weeks, days, hours, mins and secs.",
+ arguments = """
+ Arguments:
+ * years - the number of years, positive or negative
+ * months - the number of months, positive or negative
+ * days - the number of days, positive or negative
+ * hours - the number of hours, positive or negative
+ * mins - the number of minutes, positive or negative
+ * secs - the number of seconds with the fractional part in microsecond
precision.
+ """,
+ examples = """
+ Examples:
+ > SELECT _FUNC_(100, 11, 1, 1, 12, 30, 01.001001);
+ 100 years 11 months 8 days 12 hours 30 minutes 1.001001 seconds
+ > SELECT _FUNC_(100, null, 3);
+ NULL
+ """,
+ since = "3.0.0")
+// scalastyle:on line.size.limit
+case class MakeInterval(
+ years: Expression,
+ months: Expression,
+ weeks: Expression,
+ days: Expression,
+ hours: Expression,
+ mins: Expression,
+ secs: Expression)
+ extends SeptenaryExpression with ImplicitCastInputTypes {
+
+ def this(
+ years: Expression,
+ months: Expression,
+ weeks: Expression,
+ days: Expression,
+ hours: Expression,
+ mins: Expression) = {
+ this(years, months, weeks, days, hours, mins, Literal(Decimal(0, 8, 6)))
+ }
+ def this(
Review comment:
~new line before this.~ Never mind. I noticed that you collect all
constructors as a single group.
----------------------------------------------------------------
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]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]