Skip to content

Apache DataFusion SQL Query Engine

ARROW-5950: [Rust][DataFusion] Add logger

Heres, Daniel3ebd1475c327
diff --git a/rust/benchmarks/Cargo.toml b/rust/benchmarks/Cargo.toml
index 6017d88e1e..617c1c5d02 100644
--- a/rust/benchmarks/Cargo.toml
+++ b/rust/benchmarks/Cargo.toml
@@ -31,4 +31,5 @@ parquet = { path = "../parquet" }
datafusion = { path = "../datafusion" }
structopt = { version = "0.3", default-features = false }
tokio = { version = "0.2", features = ["macros", "rt-core", "rt-threaded"] }
-futures = "0.3"
\ No newline at end of file
+futures = "0.3"
+env_logger = "^0.8"
\ No newline at end of file
diff --git a/rust/benchmarks/src/bin/tpch.rs b/rust/benchmarks/src/bin/tpch.rs
index b78ea626bf..6c5d06cf37 100644
--- a/rust/benchmarks/src/bin/tpch.rs
+++ b/rust/benchmarks/src/bin/tpch.rs
@@ -109,6 +109,8 @@ async fn main() -> Result<()> {
}
async fn benchmark(opt: BenchmarkOpt) -> Result<()> {
+ env_logger::init();
+
println!("Running benchmarks with the following options: {:?}", opt);
let config = ExecutionConfig::new()
.with_concurrency(opt.concurrency)
diff --git a/rust/datafusion/Cargo.toml b/rust/datafusion/Cargo.toml
index 3108f0c5ce..8148565cb7 100644
--- a/rust/datafusion/Cargo.toml
+++ b/rust/datafusion/Cargo.toml
@@ -60,6 +60,7 @@ async-trait = "0.1.41"
futures = "0.3"
pin-project-lite= "^0.2.0"
tokio = { version = "0.2", features = ["macros", "rt-core", "rt-threaded", "sync"] }
+log = "^0.4"
[dev-dependencies]
rand = "0.7"
diff --git a/rust/datafusion/src/execution/context.rs b/rust/datafusion/src/execution/context.rs
index 33d84e1c31..eddefb1100 100644
--- a/rust/datafusion/src/execution/context.rs
+++ b/rust/datafusion/src/execution/context.rs
@@ -16,8 +16,8 @@
// under the License.
//! ExecutionContext contains methods for registering data sources and executing queries
-
use crate::optimizer::hash_build_probe_order::HashBuildProbeOrder;
+use log::debug;
use std::fs;
use std::path::Path;
use std::string::String;
@@ -316,9 +316,11 @@ impl ExecutionContext {
/// Optimize the logical plan by applying optimizer rules
pub fn optimize(&self, plan: &LogicalPlan) -> Result<LogicalPlan> {
// Apply standard rewrites and optimizations
+ debug!("Logical plan:\n {:?}", plan);
let mut plan = ProjectionPushDown::new().optimize(&plan)?;
plan = FilterPushDown::new().optimize(&plan)?;
plan = HashBuildProbeOrder::new().optimize(&plan)?;
+ debug!("Optimized logical plan:\n {:?}", plan);
self.state
.lock()