Skip to main content

query/
optimizer.rs

1// Copyright 2023 Greptime Team
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15pub mod const_normalization;
16pub mod constant_term;
17pub mod count_nest_aggr;
18pub mod count_wildcard;
19pub mod enforce_sorting;
20pub(crate) mod expr_depth;
21pub(crate) mod factorized_join_agg;
22pub mod global_limit;
23pub mod global_topk;
24pub(crate) mod infer_aggregate_input_bounds;
25pub(crate) mod insert_assignment;
26pub(crate) mod json_schema_concretize;
27pub(crate) mod json_type_concretize;
28pub(crate) mod merge_scan_projection;
29pub mod parallelize_scan;
30pub mod promql_tsid_narrow_join;
31pub mod remove_duplicate;
32pub mod scan_hint;
33pub mod series_frame_output;
34pub(crate) mod sst_manifest_aggregate;
35pub mod string_normalization;
36#[cfg(test)]
37pub(crate) mod test_util;
38pub mod topk_filter_batch;
39pub mod transcribe_atat;
40pub mod type_conversion;
41pub mod windowed_sort;
42
43use datafusion_common::Result;
44use datafusion_common::config::ConfigOptions;
45use datafusion_expr::LogicalPlan;
46
47use crate::QueryEngineContext;
48
49/// [`ExtensionAnalyzerRule`]s transform [`LogicalPlan`]s in some way to make
50/// the plan valid prior to the rest of the DataFusion optimization process.
51/// It's an extension of datafusion [`AnalyzerRule`]s but accepts [`QueryEngineContext`] as the second parameter.
52pub trait ExtensionAnalyzerRule {
53    /// Rewrite `plan`
54    fn analyze(
55        &self,
56        plan: LogicalPlan,
57        ctx: &QueryEngineContext,
58        config: &ConfigOptions,
59    ) -> Result<LogicalPlan>;
60}