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