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 constant_term;
16pub mod count_nest_aggr;
17pub mod count_wildcard;
18pub(crate) mod json_type_concretize;
19pub mod parallelize_scan;
20pub mod pass_distribution;
21pub mod remove_duplicate;
22pub mod scan_hint;
23pub mod string_normalization;
24#[cfg(test)]
25pub(crate) mod test_util;
26pub mod transcribe_atat;
27pub mod type_conversion;
28pub mod windowed_sort;
29
30use datafusion_common::Result;
31use datafusion_common::config::ConfigOptions;
32use datafusion_expr::LogicalPlan;
33
34use crate::QueryEngineContext;
35
36/// [`ExtensionAnalyzerRule`]s transform [`LogicalPlan`]s in some way to make
37/// the plan valid prior to the rest of the DataFusion optimization process.
38/// It's an extension of datafusion [`AnalyzerRule`]s but accepts [`QueryEngineContext`] as the second parameter.
39pub trait ExtensionAnalyzerRule {
40    /// Rewrite `plan`
41    fn analyze(
42        &self,
43        plan: LogicalPlan,
44        ctx: &QueryEngineContext,
45        config: &ConfigOptions,
46    ) -> Result<LogicalPlan>;
47}