File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -1150,7 +1150,17 @@ impl<'a> SqlQueryPlanner<'a> {
11501150 // Important: keep `field` even when `expr` is a BinaryOperator (e.g. `INTERVAL '1' + '2' DAY`).
11511151 let value = self . fold_interval_quantity ( expr) ?;
11521152 let interval_val = format ! ( "{} {}" , value, field) ;
1153- let config = IntervalParseConfig :: new ( IntervalUnit :: Second ) ;
1153+ // IMPORTANT: the parse unit must match the interval field being parsed.
1154+ // We store the result as IntervalMonthDayNano, but Arrow's parser still needs the
1155+ // correct base unit to interpret the textual interval accurately.
1156+ let config = IntervalParseConfig :: new ( match field {
1157+ IntervalFields :: Year => IntervalUnit :: Year ,
1158+ IntervalFields :: Month => IntervalUnit :: Month ,
1159+ IntervalFields :: Day => IntervalUnit :: Day ,
1160+ IntervalFields :: Hour => IntervalUnit :: Hour ,
1161+ IntervalFields :: Minute => IntervalUnit :: Minute ,
1162+ IntervalFields :: Second => IntervalUnit :: Second ,
1163+ } ) ;
11541164 let val = parse_interval_month_day_nano_config ( & interval_val, config) ?;
11551165
11561166 Ok ( LogicalExpr :: Literal ( ScalarValue :: IntervalMonthDayNano ( Some ( val) ) ) )
You can’t perform that action at this time.
0 commit comments