Skip to content

Commit 1dbec3e

Browse files
authored
adding expr to string for IsNotNull IsTrue IsFalse and IsUnkown (#9739)
* adding expr to string for IsNotNull IsTrue IsFalse and IsUnkown * fix clippy * change to raw string
1 parent 6c63051 commit 1dbec3e

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

datafusion/sql/src/unparser/expr.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,18 @@ impl Unparser<'_> {
181181
negated: insubq.negated,
182182
})
183183
}
184+
Expr::IsNotNull(expr) => {
185+
Ok(ast::Expr::IsNotNull(Box::new(self.expr_to_sql(expr)?)))
186+
}
187+
Expr::IsTrue(expr) => {
188+
Ok(ast::Expr::IsTrue(Box::new(self.expr_to_sql(expr)?)))
189+
}
190+
Expr::IsFalse(expr) => {
191+
Ok(ast::Expr::IsFalse(Box::new(self.expr_to_sql(expr)?)))
192+
}
193+
Expr::IsUnknown(expr) => {
194+
Ok(ast::Expr::IsUnknown(Box::new(self.expr_to_sql(expr)?)))
195+
}
184196
_ => not_impl_err!("Unsupported expression: {expr:?}"),
185197
}
186198
}
@@ -599,6 +611,19 @@ mod tests {
599611
}),
600612
"COUNT(DISTINCT *)",
601613
),
614+
(Expr::IsNotNull(Box::new(col("a"))), r#""a" IS NOT NULL"#),
615+
(
616+
Expr::IsTrue(Box::new((col("a") + col("b")).gt(lit(4)))),
617+
r#"(("a" + "b") > 4) IS TRUE"#,
618+
),
619+
(
620+
Expr::IsFalse(Box::new((col("a") + col("b")).gt(lit(4)))),
621+
r#"(("a" + "b") > 4) IS FALSE"#,
622+
),
623+
(
624+
Expr::IsUnknown(Box::new((col("a") + col("b")).gt(lit(4)))),
625+
r#"(("a" + "b") > 4) IS UNKNOWN"#,
626+
),
602627
];
603628

604629
for (expr, expected) in tests {

0 commit comments

Comments
 (0)