disable distinct without index_experimental

distinct uses indexes, therefore we need to disable them
This commit is contained in:
Pere Diaz Bou
2025-06-16 14:11:51 +02:00
parent 9ae4563bcd
commit dde93e8deb
2 changed files with 25 additions and 0 deletions

View File

@@ -50,6 +50,14 @@ pub fn resolve_aggregates(top_level_expr: &Expr, aggs: &mut Vec<Aggregate>) -> R
{
Ok(Func::Agg(f)) => {
let distinctness = Distinctness::from_ast(distinctness.as_ref());
#[cfg(not(feature = "index_experimental"))]
{
if distinctness.is_distinct() {
crate::bail_parse_error!(
"SELECT with DISTINCT is not allowed without indexes enabled"
);
}
}
let num_args = args.as_ref().map_or(0, |args| args.len());
if distinctness.is_distinct() && num_args != 1 {
crate::bail_parse_error!(

View File

@@ -202,6 +202,14 @@ fn prepare_one_select_plan<'a>(
distinctness,
..
} = *select_inner;
#[cfg(not(feature = "index_experimental"))]
{
if distinctness.is_some() {
crate::bail_parse_error!(
"SELECT with DISTINCT is not allowed without indexes enabled"
);
}
}
let col_count = columns.len();
if col_count == 0 {
crate::bail_parse_error!("SELECT without columns is not allowed");
@@ -336,6 +344,15 @@ fn prepare_one_select_plan<'a>(
0
};
let distinctness = Distinctness::from_ast(distinctness.as_ref());
#[cfg(not(feature = "index_experimental"))]
{
if distinctness.is_distinct() {
crate::bail_parse_error!(
"SELECT with DISTINCT is not allowed without indexes enabled"
);
}
}
if distinctness.is_distinct() && args_count != 1 {
crate::bail_parse_error!("DISTINCT aggregate functions must have exactly one argument");
}