[ https://issues.apache.org/jira/browse/SPARK-29679?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17139339#comment-17139339 ]
Bart Samwel commented on SPARK-29679: ------------------------------------- I think there is a way to make this work in a reasonable way, consistent with SQL standard semantics. Even though Spark intervals mix year-month and day-second intervals in one type, we can make it work consistently with the ANSI SQL definition as long as interval types are of the same kind, and do something reasonable for everything else. We can simply compare the fields \{months, days, microseconds} lexicographically, but we would have to normalize first. Normalization means taking the whole days out of the microseconds field and adding them to the days. According to the SQL standard a day is 24 hours, so this normalization is "safe", and it avoids weirdnesses such as INTERVAL 3 DAYS 2 HOURS being larger than INTERVAL 2 DAYS 26 HOURS. This type of comparison is standards compliant as long as the intervals are standards compliant. [~Qin Yao] [~cloud_fan] WDYT? > Make interval type camparable and orderable > ------------------------------------------- > > Key: SPARK-29679 > URL: https://issues.apache.org/jira/browse/SPARK-29679 > Project: Spark > Issue Type: Sub-task > Components: SQL > Affects Versions: 3.0.0 > Reporter: Kent Yao > Assignee: Kent Yao > Priority: Major > Fix For: 3.0.0 > > > {code:sql} > postgres=# select INTERVAL '9 years 1 months -1 weeks -4 days -10 hours -46 > minutes' > interval '1 s'; > ?column? > ---------- > t > (1 row) > {code} -- This message was sent by Atlassian Jira (v8.3.4#803005) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org