Skip to content

Commit 0519c4c

Browse files
Dandandanalamb
authored andcommitted
ARROW-5950: [Rust][DataFusion] Add logger
It seems useful to me to do some extra (debug, info, etc) logging. I added to the benchmark. Executing with `RUST_LOG="debug"` gives (next to sqlparser logs): ``` [2020-12-21T23:04:59Z DEBUG datafusion::execution::context] Logical plan: Sort: #l_returnflag ASC NULLS FIRST, #l_linestatus ASC NULLS FIRST Projection: #l_returnflag, #l_linestatus, #SUM(l_quantity) AS sum_qty, #SUM(l_extendedprice) AS sum_base_price, #SUM(l_extendedprice Multiply Int64(1) Minus l_discount) AS sum_disc_price, #SUM(l_extendedprice Multiply Int64(1) Minus l_discount Multiply Int64(1) Plus l_tax) AS sum_charge, #AVG(l_quantity) AS avg_qty, #AVG(l_extendedprice) AS avg_price, #AVG(l_discount) AS avg_disc, #COUNT(UInt8(1)) AS count_order Aggregate: groupBy=[[#l_returnflag, #l_linestatus]], aggr=[[SUM(#l_quantity), SUM(#l_extendedprice), SUM(#l_extendedprice Multiply Int64(1) Minus #l_discount), SUM(#l_extendedprice Multiply Int64(1) Minus #l_discount Multiply Int64(1) Plus #l_tax), AVG(#l_quantity), AVG(#l_extendedprice), AVG(#l_discount), COUNT(UInt8(1))]] Filter: #l_shipdate LtEq CAST(Utf8("1998-09-02") AS Date32(Day)) TableScan: lineitem projection=None [2020-12-21T23:04:59Z DEBUG datafusion::execution::context] Optimized logical plan: Sort: #l_returnflag ASC NULLS FIRST, #l_linestatus ASC NULLS FIRST Projection: #l_returnflag, #l_linestatus, #SUM(l_quantity) AS sum_qty, #SUM(l_extendedprice) AS sum_base_price, #SUM(l_extendedprice Multiply Int64(1) Minus l_discount) AS sum_disc_price, #SUM(l_extendedprice Multiply Int64(1) Minus l_discount Multiply Int64(1) Plus l_tax) AS sum_charge, #AVG(l_quantity) AS avg_qty, #AVG(l_extendedprice) AS avg_price, #AVG(l_discount) AS avg_disc, #COUNT(UInt8(1)) AS count_order Aggregate: groupBy=[[#l_returnflag, #l_linestatus]], aggr=[[SUM(#l_quantity), SUM(#l_extendedprice), SUM(#l_extendedprice Multiply Int64(1) Minus #l_discount), SUM(#l_extendedprice Multiply Int64(1) Minus #l_discount Multiply Int64(1) Plus #l_tax), AVG(#l_quantity), AVG(#l_extendedprice), AVG(#l_discount), COUNT(UInt8(1))]] Filter: #l_shipdate LtEq CAST(Utf8("1998-09-02") AS Date32(Day)) TableScan: lineitem projection=Some([4, 5, 6, 7, 8, 9, 10]) Query 1 iteration 9 took 802.7 ms Query 1 avg time: 915.30 ms ``` Closes #8986 from Dandandan/add_logger Lead-authored-by: Heres, Daniel <[email protected]> Co-authored-by: Daniël Heres <[email protected]> Signed-off-by: Andrew Lamb <[email protected]>
1 parent 1d874fa commit 0519c4c

File tree

5 files changed

+11
-4
lines changed

5 files changed

+11
-4
lines changed

rust/arrow-flight/src/arrow.flight.protocol.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,8 +498,9 @@ pub mod flight_service_server {
498498
#[async_trait]
499499
pub trait FlightService: Send + Sync + 'static {
500500
#[doc = "Server streaming response type for the Handshake method."]
501-
type HandshakeStream: Stream<Item = Result<super::HandshakeResponse, tonic::Status>>
502-
+ Send
501+
type HandshakeStream: Stream<
502+
Item = Result<super::HandshakeResponse, tonic::Status>,
503+
> + Send
503504
+ Sync
504505
+ 'static;
505506
#[doc = ""]

rust/benchmarks/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@ parquet = { path = "../parquet" }
3131
datafusion = { path = "../datafusion" }
3232
structopt = { version = "0.3", default-features = false }
3333
tokio = { version = "0.2", features = ["macros", "rt-core", "rt-threaded"] }
34-
futures = "0.3"
34+
futures = "0.3"
35+
env_logger = "^0.8"

rust/benchmarks/src/bin/tpch.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ async fn main() -> Result<()> {
109109
}
110110

111111
async fn benchmark(opt: BenchmarkOpt) -> Result<()> {
112+
env_logger::init();
113+
112114
println!("Running benchmarks with the following options: {:?}", opt);
113115
let config = ExecutionConfig::new()
114116
.with_concurrency(opt.concurrency)

rust/datafusion/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ async-trait = "0.1.41"
6060
futures = "0.3"
6161
pin-project-lite= "^0.2.0"
6262
tokio = { version = "0.2", features = ["macros", "rt-core", "rt-threaded", "sync"] }
63+
log = "^0.4"
6364

6465
[dev-dependencies]
6566
rand = "0.7"

rust/datafusion/src/execution/context.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
// under the License.
1717

1818
//! ExecutionContext contains methods for registering data sources and executing queries
19-
2019
use crate::optimizer::hash_build_probe_order::HashBuildProbeOrder;
20+
use log::debug;
2121
use std::fs;
2222
use std::path::Path;
2323
use std::string::String;
@@ -316,9 +316,11 @@ impl ExecutionContext {
316316
/// Optimize the logical plan by applying optimizer rules
317317
pub fn optimize(&self, plan: &LogicalPlan) -> Result<LogicalPlan> {
318318
// Apply standard rewrites and optimizations
319+
debug!("Logical plan:\n {:?}", plan);
319320
let mut plan = ProjectionPushDown::new().optimize(&plan)?;
320321
plan = FilterPushDown::new().optimize(&plan)?;
321322
plan = HashBuildProbeOrder::new().optimize(&plan)?;
323+
debug!("Optimized logical plan:\n {:?}", plan);
322324

323325
self.state
324326
.lock()

0 commit comments

Comments
 (0)