lidavidm commented on code in PR #418:
URL: https://github.com/apache/arrow-go/pull/418#discussion_r2160028518


##########
arrow/compute/utils.go:
##########
@@ -353,19 +354,45 @@ func commonTemporal(vals ...arrow.DataType) 
arrow.DataType {
                        }
                        zone = &ts.TimeZone
                        finestUnit = exec.Max(finestUnit, ts.Unit)
+               case arrow.TIME32, arrow.TIME64:
+                       ts := ty.(arrow.TemporalWithUnit)
+                       finestUnit = max(finestUnit, ts.TimeUnit())
+                       sawTime = true
+               case arrow.DURATION:
+                       ts := ty.(*arrow.DurationType)
+                       finestUnit = max(finestUnit, ts.Unit)
+                       sawDuration = true
                default:
                        return nil
                }
        }
 
-       switch {
-       case zone != nil:
-               // at least one timestamp seen
-               return &arrow.TimestampType{Unit: finestUnit, TimeZone: *zone}
-       case sawDate64:
-               return arrow.FixedWidthTypes.Date64
-       case sawDate32:
-               return arrow.FixedWidthTypes.Date32
+       sawTimestampOrDate := zone != nil || sawDate32 || sawDate64 || 
sawDuration

Review Comment:
   nit: this also includes duration



##########
arrow/compute/utils.go:
##########
@@ -353,19 +354,45 @@ func commonTemporal(vals ...arrow.DataType) 
arrow.DataType {
                        }
                        zone = &ts.TimeZone
                        finestUnit = exec.Max(finestUnit, ts.Unit)
+               case arrow.TIME32, arrow.TIME64:
+                       ts := ty.(arrow.TemporalWithUnit)
+                       finestUnit = max(finestUnit, ts.TimeUnit())
+                       sawTime = true
+               case arrow.DURATION:
+                       ts := ty.(*arrow.DurationType)
+                       finestUnit = max(finestUnit, ts.Unit)
+                       sawDuration = true
                default:
                        return nil
                }
        }
 
-       switch {
-       case zone != nil:
-               // at least one timestamp seen
-               return &arrow.TimestampType{Unit: finestUnit, TimeZone: *zone}
-       case sawDate64:
-               return arrow.FixedWidthTypes.Date64
-       case sawDate32:
-               return arrow.FixedWidthTypes.Date32
+       sawTimestampOrDate := zone != nil || sawDate32 || sawDate64 || 
sawDuration
+
+       if sawTime && sawTimestampOrDate {
+               // no common type possible
+               return nil
+       }
+

Review Comment:
   This blocks (time AND any other type) but I would assume (duration AND any 
other type) is also out of the question? 



##########
arrow/compute/utils.go:
##########
@@ -353,19 +354,45 @@ func commonTemporal(vals ...arrow.DataType) 
arrow.DataType {
                        }
                        zone = &ts.TimeZone
                        finestUnit = exec.Max(finestUnit, ts.Unit)
+               case arrow.TIME32, arrow.TIME64:
+                       ts := ty.(arrow.TemporalWithUnit)
+                       finestUnit = max(finestUnit, ts.TimeUnit())
+                       sawTime = true
+               case arrow.DURATION:
+                       ts := ty.(*arrow.DurationType)
+                       finestUnit = max(finestUnit, ts.Unit)
+                       sawDuration = true
                default:
                        return nil
                }
        }
 
-       switch {
-       case zone != nil:
-               // at least one timestamp seen
-               return &arrow.TimestampType{Unit: finestUnit, TimeZone: *zone}
-       case sawDate64:
-               return arrow.FixedWidthTypes.Date64
-       case sawDate32:
-               return arrow.FixedWidthTypes.Date32
+       sawTimestampOrDate := zone != nil || sawDate32 || sawDate64 || 
sawDuration
+
+       if sawTime && sawTimestampOrDate {
+               // no common type possible
+               return nil
+       }
+

Review Comment:
   Maybe all these checks could be combined into the three cases (saw timestamp 
or date and not time or duration) and (saw time and not anything else) and (saw 
duration and not anything else)?



##########
arrow/compute/utils.go:
##########


Review Comment:
   Personally, I think commonTemporal is complicated enough to potentially 
warrant specific unit tests for it



-- 
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: github-unsubscr...@arrow.apache.org

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

Reply via email to