Skip to content

Commit

Permalink
feat(rust): IR formatting QoL improvements (#20246)
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 authored Dec 10, 2024
1 parent 8c39bb9 commit b12a543
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
6 changes: 6 additions & 0 deletions crates/polars-plan/src/plans/ir/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,12 @@ impl Display for IRDisplay<'_> {
}
}

impl fmt::Debug for IRDisplay<'_> {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
Display::fmt(&self, f)
}
}

impl<T: AsExpr> Display for ExprIRSliceDisplay<'_, T> {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
// Display items in slice delimited by a comma
Expand Down
4 changes: 3 additions & 1 deletion crates/polars-plan/src/plans/ir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use polars_utils::unitvec;
pub use scan_sources::{ScanSourceIter, ScanSourceRef, ScanSources};
#[cfg(feature = "ir_serde")]
use serde::{Deserialize, Serialize};
use strum_macros::IntoStaticStr;

use crate::prelude::*;

Expand All @@ -36,8 +37,9 @@ pub struct IRPlanRef<'a> {

/// [`IR`] is a representation of [`DslPlan`] with [`Node`]s which are allocated in an [`Arena`]
/// In this IR the logical plan has access to the full dataset.
#[derive(Clone, Debug, Default)]
#[derive(Clone, Debug, Default, IntoStaticStr)]
#[cfg_attr(feature = "ir_serde", derive(Serialize, Deserialize))]
#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
pub enum IR {
#[cfg(feature = "python")]
PythonScan {
Expand Down
2 changes: 1 addition & 1 deletion crates/polars-plan/src/plans/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ impl DslPlan {
struct DslPlanDisplay(IRPlan);
impl fmt::Display for DslPlanDisplay {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.0.as_ref().display().fmt(f)
fmt::Display::fmt(&self.0.as_ref().display(), f)
}
}
Ok(DslPlanDisplay(self.clone().to_alp()?))
Expand Down

0 comments on commit b12a543

Please sign in to comment.