From c60e3d5cf7c2434ac58ea045c8cb45be91f7018e Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Wed, 13 Nov 2024 22:59:43 +0200 Subject: [PATCH] cql3: statement_restrictions: multi-key clustering restrictions one layer deeper For the multi column binary operator case, perform more of the work at prepare time in preparation for consolidating the analysis. --- cql3/restrictions/statement_restrictions.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cql3/restrictions/statement_restrictions.cc b/cql3/restrictions/statement_restrictions.cc index 6751f7fc8f..07aa8a527e 100644 --- a/cql3/restrictions/statement_restrictions.cc +++ b/cql3/restrictions/statement_restrictions.cc @@ -2718,13 +2718,14 @@ statement_restrictions::build_get_clustering_bounds_fn() const { }; } if (find_binop(_clustering_prefix_restrictions[0].filter, is_multi_column)) { // FIXME: adjust for solve_for - return [&] (const query_options& options) -> std::vector { bool all_natural = true, all_reverse = true; ///< Whether column types are reversed or natural. for (auto& r : _clustering_prefix_restrictions | std::views::transform(&predicate::filter)) { // TODO: move to constructor, do only once. using namespace expr; const auto& binop = expr::as(r); if (is_clustering_order(binop)) { + return [this] (const query_options& options) -> std::vector { return {range_from_raw_bounds(_clustering_prefix_restrictions, options, *_schema)}; + }; } for (auto& element : expr::as(binop.lhs).elements) { auto& cv = expr::as(element); @@ -2735,6 +2736,7 @@ statement_restrictions::build_get_clustering_bounds_fn() const { } } } + return [this, all_natural, all_reverse] (const query_options& options) -> std::vector { return get_multi_column_clustering_bounds(options, _schema, _clustering_prefix_restrictions, all_natural, all_reverse); };