Skip to content

Commit

Permalink
Merge 4f719e5 into a86c58b
Browse files Browse the repository at this point in the history
  • Loading branch information
devanbenz committed May 5, 2024
2 parents a86c58b + 4f719e5 commit b869348
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,11 @@ pub enum Expr {
OuterJoin(Box<Expr>),
/// A reference to the prior level in a CONNECT BY clause.
Prior(Box<Expr>),
/// Scalar variable creation e.g. `[@]foo INT`
ScalarVariable {
data_type: DataType,
name: String,
},
}

impl fmt::Display for CastFormat {
Expand Down Expand Up @@ -1241,6 +1246,9 @@ impl fmt::Display for Expr {
write!(f, "{expr} (+)")
}
Expr::Prior(expr) => write!(f, "PRIOR {expr}"),
Expr::ScalarVariable { data_type, name } => {
write!(f, "{name} {data_type}")
}
}
}
}
Expand Down Expand Up @@ -6441,6 +6449,24 @@ mod tests {
assert_eq!("CUBE (a, (b, c), d)", format!("{cube}"));
}

#[test]
fn test_scalar_variable_display() {
let scalar_variable = Expr::ScalarVariable {
data_type: DataType::Boolean,
name: "foo".to_string(),
};
assert_eq!("foo BOOLEAN", format!("{scalar_variable}"));
}

#[test]
fn test_scalar_variable_display_int() {
let scalar_variable = Expr::ScalarVariable {
data_type: DataType::Int(None),
name: "foo".to_string(),
};
assert_eq!("foo INT", format!("{scalar_variable}"));
}

#[test]
fn test_interval_display() {
let interval = Expr::Interval(Interval {
Expand Down

0 comments on commit b869348

Please sign in to comment.