Skip to content

Commit 41cb1b6

Browse files
authored
feat: teach ScopeDType to Display (#3616)
The debug output is way too verbose to be useful.
1 parent 96bbf63 commit 41cb1b6

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

vortex-expr/src/scope.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
use std::any::Any;
2+
use std::fmt::Display;
23
use std::str::FromStr;
34
use std::sync::Arc;
45

6+
use itertools::Itertools;
57
use vortex_array::{Array, ArrayRef};
68
use vortex_dtype::{DType, FieldPathSet};
79
use vortex_error::{VortexError, VortexResult, vortex_bail, vortex_err};
@@ -52,7 +54,7 @@ impl Identifier {
5254
}
5355
}
5456

55-
impl std::fmt::Display for Identifier {
57+
impl Display for Identifier {
5658
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5759
match self {
5860
Identifier::Identity => write!(f, ""),
@@ -176,6 +178,25 @@ pub struct ScopeDType {
176178
types: ExprScope<DType>,
177179
}
178180

181+
impl Display for ScopeDType {
182+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
183+
if let Some(root) = self.root.as_ref() {
184+
write!(f, "$: {}", root)?;
185+
}
186+
if !self.types.is_empty() {
187+
write!(f, ". ")?;
188+
write!(
189+
f,
190+
"{}",
191+
self.types
192+
.iter()
193+
.format_with(",", |x, f| f(&format_args!("{}: {}", x.0, x.1)))
194+
)?;
195+
}
196+
Ok(())
197+
}
198+
}
199+
179200
pub type ScopeDTypeElement = (Identifier, DType);
180201

181202
impl From<&Scope> for ScopeDType {

0 commit comments

Comments
 (0)