You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "yaooqinn (via GitHub)" <gi...@apache.org> on 2024/01/02 02:56:08 UTC

Re: [PR] [SPARK-46536][SQL] Support GROUP BY calendar_interval_type [spark]

yaooqinn commented on code in PR #44538:
URL: https://github.com/apache/spark/pull/44538#discussion_r1439129096


##########
common/unsafe/src/main/java/org/apache/spark/unsafe/types/CalendarInterval.java:
##########
@@ -127,4 +127,15 @@ private void appendUnit(StringBuilder sb, long value, String unit) {
    * @throws ArithmeticException if a numeric overflow occurs
    */
   public Duration extractAsDuration() { return Duration.of(microseconds, ChronoUnit.MICROS); }
+
+  @Override
+  public int compareTo(CalendarInterval o) {
+    if (this.months != o.months) {

Review Comment:
   Comparing intervals does not necessarily short circuits via months. We could result in `1 month > 0 months 32 days`, which is wrong, obviously.
   
   Besides, 1 month can be 28 ~ 30 days, making the legacy calendar interval type uncomparable



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org