You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
for scalar in start.iter_mut().chain(end.iter_mut()){
384
-
let ty = scalar.as_ref().infer_data_type();
385
-
common_ty = common_super_type(
386
-
common_ty.clone(),
387
-
ty.clone(),
388
-
&BUILTIN_FUNCTIONS.default_cast_rules,
389
-
)
390
-
.ok_or_else(|| {
391
-
ErrorCode::IllegalDataType(format!(
392
-
"Cannot find common type for {:?} and {:?}",
393
-
&common_ty,&ty
394
-
))
395
-
})?;
396
-
}
371
+
if common_ty.remove_nullable().is_timestamp(){
372
+
for scalar in start.iter_mut().chain(end.iter_mut()){
373
+
let scalar_ty = scalar.as_ref().infer_data_type();
374
+
if !scalar_ty.is_interval(){
375
+
returnErr(ErrorCode::IllegalDataType(format!("when the type of the order by in window func is Timestamp, Preceding and Following can only be INTERVAL types, but get {}", scalar_ty)));
376
+
}
377
+
}
378
+
}elseif common_ty.remove_nullable().is_date(){
379
+
letmut last_ty = None;
380
+
for scalar in start.iter_mut().chain(end.iter_mut()){
381
+
let scalar_ty = scalar.as_ref().infer_data_type();
382
+
if !scalar_ty.is_interval() && !scalar_ty.is_unsigned_numeric(){
383
+
returnErr(ErrorCode::IllegalDataType(format!("when the type of the order by in window func is Date, Preceding and Following can only be INTERVAL or Unsigned Integer types, but get {}", scalar_ty)));
384
+
}
385
+
if last_ty.as_ref().is_none_or(|ty| ty == &scalar_ty){
386
+
last_ty = Some(scalar_ty);
387
+
continue;
388
+
}
389
+
returnErr(ErrorCode::IllegalDataType(format!("when the type of the order by in window func is Date, Preceding and Following can only be of the same type, but get {} and {}", last_ty.unwrap(), scalar_ty)));
390
+
}
391
+
}else{
392
+
for scalar in start.iter_mut().chain(end.iter_mut()){
393
+
let ty = scalar.as_ref().infer_data_type();
394
+
common_ty = common_super_type(
395
+
common_ty.clone(),
396
+
ty.clone(),
397
+
&BUILTIN_FUNCTIONS.default_cast_rules,
398
+
)
399
+
.ok_or_else(|| {
400
+
ErrorCode::IllegalDataType(format!(
401
+
"Cannot find common type for {:?} and {:?}",
402
+
&common_ty,&ty
403
+
))
404
+
})?;
405
+
}
406
+
*order_by = wrap_cast(order_by,&common_ty);
397
407
398
-
*order_by = wrap_cast(order_by,&common_ty);
399
-
for scalar in start.iter_mut().chain(end.iter_mut()){
400
-
let raw_expr = RawExpr::<usize>::Cast{
401
-
span: w.span,
402
-
is_try:false,
403
-
expr:Box::new(RawExpr::Constant{
408
+
for scalar in start.iter_mut().chain(end.iter_mut()){
409
+
let raw_expr = RawExpr::<usize>::Cast{
404
410
span: w.span,
405
-
scalar: scalar.clone(),
406
-
data_type:None,
407
-
}),
408
-
dest_type: common_ty.clone(),
409
-
};
410
-
let expr = type_check::check(&raw_expr,&BUILTIN_FUNCTIONS)?;
0 commit comments