Files
scylladb/cql3/selection/selector.cc
Avi Kivity 91b251f6b4 cql3: selection: convert processes_selection to work on prepared expressions
processes_selection() checks whether a selector passes-through a column
or applies some form of processing (like a case or function application).

It's more sensible to do this in the prepared domain as we have more
information about the expression. It doesn't really help here, but
it does help the refactoring later in the series.
2023-07-03 19:45:17 +03:00

61 lines
1.6 KiB
C++

/*
* Copyright (C) 2015-present ScyllaDB
*/
/*
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
#include "selector.hh"
#include "raw_selector.hh"
#include "cql3/column_identifier.hh"
#include "cql3/expr/expr-utils.hh"
namespace cql3 {
namespace selection {
lw_shared_ptr<column_specification>
selector::factory::get_column_specification(const schema& schema) const {
return make_lw_shared<column_specification>(schema.ks_name(),
schema.cf_name(),
::make_shared<column_identifier>(column_name(), true),
get_return_type());
}
bool selector::requires_thread() const { return false; }
std::vector<prepared_selector>
raw_selector::to_prepared_selectors(const std::vector<::shared_ptr<raw_selector>>& raws,
const schema& schema, data_dictionary::database db, const sstring& ks) {
std::vector<prepared_selector> r;
r.reserve(raws.size());
for (auto&& raw : raws) {
r.emplace_back(prepared_selector{
.expr = expr::prepare_expression(raw->selectable_, db, ks, &schema, nullptr),
.alias = raw->alias,
});
}
return r;
}
std::vector<shared_ptr<selectable>>
to_selectables(std::span<const prepared_selector> selectors,
const schema& schema, data_dictionary::database db, const sstring& ks) {
std::vector<::shared_ptr<selectable>> r;
r.reserve(selectors.size());
for (auto&& ps : selectors) {
r.emplace_back(prepare_selectable(schema, ps.expr, db, ks));
}
return r;
}
bool
processes_selection(const prepared_selector& ps) {
return selectable_processes_selection(ps.expr);
}
}
}