Skip to content

Commit 590e7a2

Browse files
committed
fix: the align in range query must exist
1 parent e98e6b3 commit 590e7a2

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

src/parser/mod.rs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10508,6 +10508,48 @@ impl<'a> Parser<'a> {
1050810508
}
1050910509
rewrite_projection
1051010510
} else {
10511+
// `align` not found, validate `range_fn`, report an error if it contains `fill`.
10512+
10513+
let align_fill_validate = |expr: &Expr| {
10514+
rewrite_calculation_expr(expr, true, &mut |e: &Expr| match e {
10515+
Expr::Function(func) => {
10516+
if let Some(name) = func.name.0.first() {
10517+
if name.value.as_str() == "range_fn" {
10518+
let FunctionArguments::List(args) = &func.args else {
10519+
unreachable!()
10520+
};
10521+
10522+
if let Some(FunctionArg::Unnamed(FunctionArgExpr::Expr(
10523+
Expr::Value(Value::SingleQuotedString(value)),
10524+
))) = args.args.get(2)
10525+
{
10526+
if !value.is_empty() {
10527+
return Err(ParserError::ParserError(
10528+
"ALIGN argument cannot be omitted in the range select query".into(),
10529+
));
10530+
}
10531+
}
10532+
}
10533+
}
10534+
Ok(None)
10535+
}
10536+
_ => Ok(None),
10537+
})
10538+
};
10539+
10540+
projection
10541+
.iter()
10542+
.map(|select_item| {
10543+
match select_item {
10544+
SelectItem::UnnamedExpr(expr) => {
10545+
align_fill_validate(expr)?;
10546+
}
10547+
_ => {}
10548+
}
10549+
Ok(())
10550+
})
10551+
.collect::<Result<Vec<()>, ParserError>>()?;
10552+
1051110553
projection
1051210554
};
1051310555

0 commit comments

Comments
 (0)