fix offset statement error handling
@@ -53,7 +53,8 @@ impl<'a> Binder {
None => None,
};
- let offset_cnt = if let Some(Expr::Literal { span: _, lit: x }) = offset {
+ let offset_cnt = if let Some(offset) = offset {
+ if let Expr::Literal { lit: x, .. } = offset {
let box (value, data_type) = type_checker.resolve_literal(x, None)?;
if !data_type.data_type_id().is_integer() {
return Err(ErrorCode::IllegalDataType("Unsupported offset type"));
@@ -61,6 +62,12 @@ impl<'a> Binder {
value.as_u64()? as usize
} else {
0
+ }
+ } else {
+ // TODO: try fold constant expression like `1+1`
+ return Err(ErrorCode::SemanticError(
+ "Invalid OFFSET statement with non-literal expression",
+ ));
};
let limit_plan = Limit {
