Skip to main content

datafusion_optimizer/
lib.rs

1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
3// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
4
5#![doc(
6    html_logo_url = "https://raw.githubusercontent.com/apache/datafusion/19fe44cf2f30cbdd63d4a4f52c74055163c6cc38/docs/logos/standalone_logo/logo_original.svg",
7    html_favicon_url = "https://raw.githubusercontent.com/apache/datafusion/19fe44cf2f30cbdd63d4a4f52c74055163c6cc38/docs/logos/standalone_logo/logo_original.svg"
8)]
9#![cfg_attr(docsrs, feature(doc_cfg))]
10// Make sure fast / cheap clones on Arc are explicit:
11// https://github.com/apache/datafusion/issues/11143
12#![deny(clippy::clone_on_ref_ptr)]
13#![cfg_attr(test, allow(clippy::needless_pass_by_value))]
14
15//! # DataFusion Optimizer
16//!
17//! Contains rules for rewriting [`LogicalPlan`]s
18//!
19//! 1. [`Analyzer`] applies [`AnalyzerRule`]s to transform `LogicalPlan`s
20//!    to make the plan valid prior to the rest of the DataFusion optimization
21//!    process (for example, [`TypeCoercion`]).
22//!
23//! 2. [`Optimizer`] applies [`OptimizerRule`]s to transform `LogicalPlan`s
24//!    into equivalent, but more efficient plans.
25//!
26//! [`LogicalPlan`]: datafusion_expr::LogicalPlan
27//! [`TypeCoercion`]: analyzer::type_coercion::TypeCoercion
28pub mod analyzer;
29pub mod common_subexpr_eliminate;
30pub mod decorrelate;
31pub mod decorrelate_lateral_join;
32pub mod decorrelate_predicate_subquery;
33pub mod eliminate_aggregate_distinct;
34pub mod eliminate_cross_join;
35pub mod eliminate_duplicated_expr;
36pub mod eliminate_filter;
37pub mod eliminate_group_by_constant;
38pub mod eliminate_join;
39pub mod eliminate_limit;
40#[deprecated(since = "52.0.0", note = "Please use OptimizeUnions instead")]
41pub mod eliminate_nested_union {
42    use crate::optimize_unions::OptimizeUnions;
43    #[deprecated(since = "52.0.0", note = "Please use OptimizeUnions instead")]
44    pub type EliminateNestedUnion = OptimizeUnions;
45}
46pub mod eliminate_outer_join;
47pub mod extract_equijoin_predicate;
48pub mod extract_leaf_expressions;
49pub mod filter_null_join_keys;
50pub mod optimize_projections;
51pub mod optimize_unions;
52pub mod optimizer;
53pub mod propagate_empty_relation;
54pub mod push_down_filter;
55pub mod push_down_limit;
56pub mod replace_distinct_aggregate;
57pub mod rewrite_set_comparison;
58pub mod scalar_subquery_to_join;
59pub mod simplify_expressions;
60pub mod single_distinct_to_groupby;
61pub mod unions_to_filter;
62pub mod utils;
63
64#[cfg(test)]
65pub mod test;
66
67pub use analyzer::{Analyzer, AnalyzerRule};
68pub use optimizer::{
69    ApplyOrder, Optimizer, OptimizerConfig, OptimizerContext, OptimizerRule,
70};
71
72pub(crate) mod join_key_set;
73mod plan_signature;
74
75#[cfg(test)]
76#[ctor::ctor(unsafe)]
77fn init() {
78    // Enable RUST_LOG logging configuration for test
79    let _ = env_logger::try_init();
80}