Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10508,6 +10508,43 @@ impl<'a> Parser<'a> {
}
rewrite_projection
} else {
// `align` not found, report an error if the projection contains `range_fn` but without rewriting them.

let align_fill_validate = |expr: &Expr| {
rewrite_calculation_expr(expr, true, &mut |e: &Expr| match e {
Expr::Function(func) => {
if let Some(name) = func.name.0.first() {
if name.value.as_str() == "range_fn" {
let FunctionArguments::List(args) = &func.args else {
unreachable!()
};
Comment on lines +10517 to +10520
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we ensure this is unreachable? If not, can we return an error here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we can.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may use if-let or add a safety note that mentions which place ensures this.


if args.args.len() < 5 {
return Err(ParserError::ParserError(
"ALIGN argument cannot be omitted in the range select query".into(),
));
}
}
}
Ok(None)
}
_ => Ok(None),
})
};

projection
.iter()
.map(|select_item| {
match select_item {
SelectItem::UnnamedExpr(expr) => {
align_fill_validate(expr)?;
}
_ => {}
}
Ok(())
})
.collect::<Result<Vec<()>, ParserError>>()?;

projection
};

Expand Down
Loading