Skip to content

Commit

Permalink
Implement Debug for ExecutionProps and VarProvider (#5489)
Browse files Browse the repository at this point in the history
* Implement `Debug` for `ExecutionProps`

* fix examples

* fix test
  • Loading branch information
alamb committed Mar 7, 2023
1 parent a6f4a77 commit 8d8b765
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
4 changes: 2 additions & 2 deletions datafusion/core/src/test/variable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use crate::variable::VarProvider;
use arrow::datatypes::DataType;

/// System variable
#[derive(Default)]
#[derive(Default, Debug)]
pub struct SystemVar {}

impl SystemVar {
Expand All @@ -46,7 +46,7 @@ impl VarProvider for SystemVar {
}

/// user defined variable
#[derive(Default)]
#[derive(Default, Debug)]
pub struct UserDefinedVar {}

impl UserDefinedVar {
Expand Down
12 changes: 11 additions & 1 deletion datafusion/physical-expr/src/execution_props.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use std::sync::Arc;
/// done so during predicate pruning and expression simplification
///
/// [`LogicalPlan`]: datafusion_expr::LogicalPlan
#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct ExecutionProps {
pub query_execution_start_time: DateTime<Utc>,
/// Providers for scalar variables
Expand Down Expand Up @@ -85,3 +85,13 @@ impl ExecutionProps {
.and_then(|var_providers| var_providers.get(&var_type).map(Arc::clone))
}
}

#[cfg(test)]
mod test {
use super::*;
#[test]
fn debug() {
let props = ExecutionProps::new();
assert_eq!("ExecutionProps { query_execution_start_time: 1970-01-01T00:00:00Z, var_providers: None }", format!("{props:?}"));
}
}
2 changes: 1 addition & 1 deletion datafusion/physical-expr/src/var_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub enum VarType {
}

/// A var provider for @variable
pub trait VarProvider {
pub trait VarProvider: std::fmt::Debug {
/// Get variable value
fn get_value(&self, var_names: Vec<String>) -> Result<ScalarValue>;

Expand Down

0 comments on commit 8d8b765

Please sign in to comment.