From dde93e8debcfe45f28574d09713d55dbcd4174c3 Mon Sep 17 00:00:00 2001 From: Pere Diaz Bou Date: Mon, 16 Jun 2025 14:11:51 +0200 Subject: [PATCH] disable distinct without index_experimental distinct uses indexes, therefore we need to disable them --- core/translate/planner.rs | 8 ++++++++ core/translate/select.rs | 17 +++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/core/translate/planner.rs b/core/translate/planner.rs index aa21e8a34..77af53126 100644 --- a/core/translate/planner.rs +++ b/core/translate/planner.rs @@ -50,6 +50,14 @@ pub fn resolve_aggregates(top_level_expr: &Expr, aggs: &mut Vec) -> 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!( diff --git a/core/translate/select.rs b/core/translate/select.rs index 85469be64..bda9dabe2 100644 --- a/core/translate/select.rs +++ b/core/translate/select.rs @@ -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"); }