Skip to content

Commit 8dbd8bd

Browse files
committed
Add common planner
Signed-off-by: Xuanwo <github@xuanwo.io>
1 parent 89b1367 commit 8dbd8bd

28 files changed

+81
-22
lines changed

Cargo.lock

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ members = [
3030
"src/query/functions-v2",
3131
"src/query/legacy-parser",
3232
"src/query/management",
33+
"src/query/planner",
3334
"src/query/pipeline/core",
3435
"src/query/pipeline/sinks",
3536
"src/query/pipeline/sources",

src/query/planner/Cargo.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[package]
2+
name = "common-planner"
3+
version = "0.1.0"
4+
authors = ["Databend Authors <opensource@datafuselabs.com>"]
5+
license = "Apache-2.0"
6+
publish = false
7+
edition = "2021"
8+
9+
[dependencies]

src/query/planner/src/lib.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright 2022 Datafuse Labs.
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+
15+
//! Databend Planner is the core part of Databend Query, it will:
16+
//!
17+
//! - Use `Parser` (provided by `common-ast`) to parse query into AST.
18+
//! - Use `Binder` to bind query into `LogicalPlan`
19+
//! - Use `Optimizer` to optimize `LogicalPlan` into `PhysicalPlan`
20+
//!
21+
//! After all the planners work, `Interpreter` will use `PhysicalPlan` to
22+
//! build pipelines, then our processes will produce result data blocks.
23+
24+
mod metadata;
25+
pub use metadata::IndexType;

src/query/planner/src/metadata.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2022 Datafuse Labs.
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+
15+
/// Planner use [`usize`] as it's index type.
16+
///
17+
/// This type will be used across the whole planner.
18+
pub type IndexType = usize;

src/query/service/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ common-pipeline-core = { path = "../pipeline/core" }
6161
common-pipeline-sinks = { path = "../pipeline/sinks" }
6262
common-pipeline-sources = { path = "../pipeline/sources" }
6363
common-pipeline-transforms = { path = "../pipeline/transforms" }
64+
common-planner = { path = "../planner" }
6465
common-settings = { path = "../settings" }
6566
common-storage = { path = "../../common/storage" }
6667
common-storages-fuse = { path = "../storages/fuse" }

src/query/service/src/sql/planner/binder/bind_context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ use common_datavalues::DataSchemaRefExt;
2525
use common_datavalues::DataTypeImpl;
2626
use common_exception::ErrorCode;
2727
use common_exception::Result;
28+
use common_planner::IndexType;
2829
use parking_lot::RwLock;
2930

3031
use super::AggregateInfo;
3132
use crate::sql::normalize_identifier;
3233
use crate::sql::optimizer::SExpr;
33-
use crate::sql::planner::IndexType;
3434
use crate::sql::plans::Scalar;
3535
use crate::sql::NameResolutionContext;
3636

src/query/service/src/sql/planner/binder/distinct.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
use std::collections::HashMap;
1616

1717
use common_exception::Result;
18+
use common_planner::IndexType;
1819

1920
use crate::sql::binder::Binder;
2021
use crate::sql::binder::ColumnBinding;
2122
use crate::sql::optimizer::SExpr;
2223
use crate::sql::planner::semantic::GroupingChecker;
23-
use crate::sql::planner::IndexType;
2424
use crate::sql::plans::Aggregate;
2525
use crate::sql::plans::AggregateMode;
2626
use crate::sql::plans::BoundColumnRef;

src/query/service/src/sql/planner/binder/project.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use common_ast::ast::Indirection;
1818
use common_ast::ast::SelectTarget;
1919
use common_exception::ErrorCode;
2020
use common_exception::Result;
21+
use common_planner::IndexType;
2122

2223
use super::bind_context::NameResolutionResult;
2324
use crate::sql::binder::select::SelectItem;
@@ -31,7 +32,6 @@ use crate::sql::planner::binder::Binder;
3132
use crate::sql::planner::binder::ColumnBinding;
3233
use crate::sql::planner::semantic::normalize_identifier;
3334
use crate::sql::planner::semantic::GroupingChecker;
34-
use crate::sql::planner::IndexType;
3535
use crate::sql::plans::BoundColumnRef;
3636
use crate::sql::plans::EvalScalar;
3737
use crate::sql::plans::Project;

src/query/service/src/sql/planner/binder/sort.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use common_ast::ast::OrderByExpr;
2121
use common_ast::DisplayError;
2222
use common_exception::ErrorCode;
2323
use common_exception::Result;
24+
use common_planner::IndexType;
2425

2526
use super::bind_context::NameResolutionResult;
2627
use crate::sql::binder::scalar::ScalarBinder;
@@ -30,7 +31,6 @@ use crate::sql::binder::ColumnBinding;
3031
use crate::sql::normalize_identifier;
3132
use crate::sql::optimizer::SExpr;
3233
use crate::sql::planner::semantic::GroupingChecker;
33-
use crate::sql::planner::IndexType;
3434
use crate::sql::plans::AggregateFunction;
3535
use crate::sql::plans::AndExpr;
3636
use crate::sql::plans::BoundColumnRef;

0 commit comments

Comments
 (0)