@@ -688,6 +688,21 @@ fn coerce_frame_bound(
688
688
}
689
689
}
690
690
691
+ fn extract_window_frame_target_type ( col_type : & DataType ) -> Result < DataType > {
692
+ if col_type. is_numeric ( )
693
+ || is_utf8_or_large_utf8 ( & col_type)
694
+ || matches ! ( col_type, DataType :: Null )
695
+ {
696
+ Ok ( col_type. clone ( ) )
697
+ } else if is_datetime ( & col_type) {
698
+ Ok ( DataType :: Interval ( IntervalUnit :: MonthDayNano ) )
699
+ } else if let DataType :: Dictionary ( _, value_type) = col_type {
700
+ extract_window_frame_target_type ( value_type)
701
+ } else {
702
+ return internal_err ! ( "Cannot run range queries on datatype: {col_type:?}" ) ;
703
+ }
704
+ }
705
+
691
706
// Coerces the given `window_frame` to use appropriate natural types.
692
707
// For example, ROWS and GROUPS frames use `UInt64` during calculations.
693
708
fn coerce_window_frame (
@@ -703,18 +718,7 @@ fn coerce_window_frame(
703
718
. map ( |s| s. expr . get_type ( schema) )
704
719
. transpose ( ) ?;
705
720
if let Some ( col_type) = current_types {
706
- if col_type. is_numeric ( )
707
- || is_utf8_or_large_utf8 ( & col_type)
708
- || matches ! ( col_type, DataType :: Null )
709
- {
710
- col_type
711
- } else if is_datetime ( & col_type) {
712
- DataType :: Interval ( IntervalUnit :: MonthDayNano )
713
- } else {
714
- return internal_err ! (
715
- "Cannot run range queries on datatype: {col_type:?}"
716
- ) ;
717
- }
721
+ extract_window_frame_target_type ( & col_type) ?
718
722
} else {
719
723
return internal_err ! ( "ORDER BY column cannot be empty" ) ;
720
724
}
0 commit comments