From 4e64b65872c03c55edb5c6a65b1bd083267052ec Mon Sep 17 00:00:00 2001 From: Devan Date: Sun, 5 May 2024 16:47:20 -0500 Subject: [PATCH 1/3] feat/adding scalar-variable expression --- src/ast/mod.rs | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/ast/mod.rs b/src/ast/mod.rs index 32c7f6e9bd..72973a2de1 100644 --- a/src/ast/mod.rs +++ b/src/ast/mod.rs @@ -798,6 +798,16 @@ pub enum Expr { /// /// See . OuterJoin(Box), +<<<<<<< Updated upstream +======= + /// A reference to the prior level in a CONNECT BY clause. + Prior(Box), + /// Scalar variable creation e.g. `[@]foo INT` + ScalarVariable { + data_type: DataType, + name: String, + }, +>>>>>>> Stashed changes } impl fmt::Display for CastFormat { @@ -1255,6 +1265,13 @@ impl fmt::Display for Expr { Expr::OuterJoin(expr) => { write!(f, "{expr} (+)") } +<<<<<<< Updated upstream +======= + Expr::Prior(expr) => write!(f, "PRIOR {expr}"), + Expr::ScalarVariable { data_type, name } => { + write!(f, "{name} {data_type}") + } +>>>>>>> Stashed changes } } } @@ -6289,6 +6306,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 { From 96dd38220520cb0467e5783a786a81f0fc1640cd Mon Sep 17 00:00:00 2001 From: Devan Date: Sun, 5 May 2024 17:20:34 -0500 Subject: [PATCH 2/3] feat/adding scalar-variable expression --- src/ast/mod.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/ast/mod.rs b/src/ast/mod.rs index 72973a2de1..e37a29c332 100644 --- a/src/ast/mod.rs +++ b/src/ast/mod.rs @@ -798,8 +798,6 @@ pub enum Expr { /// /// See . OuterJoin(Box), -<<<<<<< Updated upstream -======= /// A reference to the prior level in a CONNECT BY clause. Prior(Box), /// Scalar variable creation e.g. `[@]foo INT` @@ -807,7 +805,6 @@ pub enum Expr { data_type: DataType, name: String, }, ->>>>>>> Stashed changes } impl fmt::Display for CastFormat { @@ -1265,13 +1262,10 @@ impl fmt::Display for Expr { Expr::OuterJoin(expr) => { write!(f, "{expr} (+)") } -<<<<<<< Updated upstream -======= Expr::Prior(expr) => write!(f, "PRIOR {expr}"), Expr::ScalarVariable { data_type, name } => { write!(f, "{name} {data_type}") } ->>>>>>> Stashed changes } } } From dd25291aa8aacf689e8c157fd5ed171ae85ab8c1 Mon Sep 17 00:00:00 2001 From: Devan Date: Mon, 6 May 2024 13:18:58 -0500 Subject: [PATCH 3/3] feat/adding scalar-variable expression --- src/ast/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ast/mod.rs b/src/ast/mod.rs index a383ea7c0c..2197bbff1f 100644 --- a/src/ast/mod.rs +++ b/src/ast/mod.rs @@ -1301,7 +1301,7 @@ impl fmt::Display for Expr { Expr::Prior(expr) => write!(f, "PRIOR {expr}"), Expr::ScalarVariable { data_type, name } => { write!(f, "{name} {data_type}") - }, + } Expr::Lambda(lambda) => write!(f, "{lambda}"), } }