Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
155 changes: 139 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ strum = "0.24"
strum_macros = "0.24"
ordered-float = "3.0"
derive-new = "0.5.9"
log = "0.4"
env_logger = "0.10"

[dev-dependencies]
test-case = "2"
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ debug:

debug_v2:
ENABLE_V2=1 RUST_BACKTRACE=1 cargo run

debug_v2_log:
RUST_LOG='sqlrs::planner=debug,sqlrs::execution=debug' ENABLE_V2=1 RUST_BACKTRACE=1 cargo run
2 changes: 2 additions & 0 deletions src/execution/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ use crate::catalog_v2::CatalogError;
use crate::main_entry::ClientContext;
use crate::types_v2::TypeError;

static LOGGING_TARGET: &str = "sqlrs::execution";

#[derive(new)]
pub struct ExecutionContext {
pub(crate) client_context: Arc<ClientContext>,
Expand Down
11 changes: 10 additions & 1 deletion src/execution/physical_plan_generator.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
use std::sync::Arc;

use derive_new::new;
use log::debug;

use super::{ColumnBindingResolver, PhysicalOperator};
use crate::execution::LOGGING_TARGET;
use crate::main_entry::ClientContext;
use crate::planner_v2::{LogicalOperator, LogicalOperatorVisitor};
use crate::util::tree_render::TreeRender;

#[derive(new)]
pub struct PhysicalPlanGenerator {
Expand All @@ -21,7 +24,13 @@ impl PhysicalPlanGenerator {
op.resolve_operator_types();

// then create the main physical plan
self.create_plan_internal(op)
let plan = self.create_plan_internal(op);
debug!(
target: LOGGING_TARGET,
"Physical Plan:\n{}",
TreeRender::physical_plan_tree(&plan),
);
plan
}

pub(crate) fn create_plan_internal(&self, op: LogicalOperator) -> PhysicalOperator {
Expand Down
2 changes: 2 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ use sqlrs::{cli, Database};

#[tokio::main]
async fn main() -> Result<()> {
env_logger::init();

let db = Database::new_on_csv();
create_csv_table(&db, "employee")?;
create_csv_table(&db, "department")?;
Expand Down
2 changes: 0 additions & 2 deletions src/planner_v2/binder/statement/bind_insert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ impl Binder {
let mut plan = select_node.plan;
// cast inserted types to expected types when necessary
self.cast_logical_operator_to_types(&inserted_types, &expected_types, &mut plan)?;
// TODO: add debug level log for plan
// println!("plan: {:#?}", plan);

let root = LogicalInsert::new(
LogicalOperatorBase::new(vec![plan], vec![], vec![]),
Expand Down
Loading