yaooqinn commented on pull request #27805:
URL: https://github.com/apache/spark/pull/27805#issuecomment-640624624
```sql
scala> spark.udf.register("div", (x: CalendarInterval, y: CalendarInterval)
=> x.microseconds / y.microseconds)
res5: org.apache.spark.sql.expressions.UserDefinedFunction =
SparkUserDefinedFunction($Lambda$3193/1435685475@9bd49ca,LongType,List(Some(class[value[0]:
interval]), Some(class[value[0]: interval])),Some(div),false,true)
scala> spark.sql("select div(interval 24 hour, interval 1 hour 30
minutes)").show
+---------------------------------+
|div(24 hours, 1 hours 30 minutes)|
+---------------------------------+
| 16|
+---------------------------------+
scala> spark.udf.register("modulo", (x: CalendarInterval, y:
CalendarInterval) => x.microseconds % y.microseconds)
res7: org.apache.spark.sql.expressions.UserDefinedFunction =
SparkUserDefinedFunction($Lambda$3231/1344928508@26fb851d,LongType,List(Some(class[value[0]:
interval]), Some(class[value[0]: interval])),Some(modulo),false,true)
scala> spark.sql("select modulo(interval 24 hour, interval 1 hour 30
minutes)").show
+------------------------------------+
|modulo(24 hours, 1 hours 30 minutes)|
+------------------------------------+
| 0|
+------------------------------------+
```
The months, days, and microseconds are all public, with UDFs, I think it's
easy to achieve what we are trying to do here.
----------------------------------------------------------------
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]