Skip to content

Commit

Permalink
Implement unparse IsNotFalse to String (#10538)
Browse files Browse the repository at this point in the history
* support to unparse IsNotFalse

* reordering expressions in pattern matching
  • Loading branch information
goldmedal authored May 16, 2024
1 parent 357987f commit ead66ac
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions datafusion/sql/src/unparser/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,9 @@ impl Unparser<'_> {
asc: _,
nulls_first: _,
}) => plan_err!("Sort expression should be handled by expr_to_unparsed"),
Expr::IsNull(expr) => {
Ok(ast::Expr::IsNull(Box::new(self.expr_to_sql(expr)?)))
}
Expr::IsNotNull(expr) => {
Ok(ast::Expr::IsNotNull(Box::new(self.expr_to_sql(expr)?)))
}
Expand All @@ -368,6 +371,9 @@ impl Unparser<'_> {
Expr::IsFalse(expr) => {
Ok(ast::Expr::IsFalse(Box::new(self.expr_to_sql(expr)?)))
}
Expr::IsNotFalse(expr) => {
Ok(ast::Expr::IsNotFalse(Box::new(self.expr_to_sql(expr)?)))
}
Expr::IsUnknown(expr) => {
Ok(ast::Expr::IsUnknown(Box::new(self.expr_to_sql(expr)?)))
}
Expand All @@ -391,10 +397,6 @@ impl Unparser<'_> {
Expr::ScalarVariable(_, _) => {
not_impl_err!("Unsupported Expr conversion: {expr:?}")
}
Expr::IsNull(expr) => {
Ok(ast::Expr::IsNull(Box::new(self.expr_to_sql(expr)?)))
}
Expr::IsNotFalse(_) => not_impl_err!("Unsupported Expr conversion: {expr:?}"),
Expr::GetIndexedField(_) => {
not_impl_err!("Unsupported Expr conversion: {expr:?}")
}
Expand Down Expand Up @@ -1116,6 +1118,10 @@ mod tests {
(col("a") + col("b")).gt(lit(4)).is_false(),
r#"(("a" + "b") > 4) IS FALSE"#,
),
(
(col("a") + col("b")).gt(lit(4)).is_not_false(),
r#"(("a" + "b") > 4) IS NOT FALSE"#,
),
(
(col("a") + col("b")).gt(lit(4)).is_unknown(),
r#"(("a" + "b") > 4) IS UNKNOWN"#,
Expand Down

0 comments on commit ead66ac

Please sign in to comment.