yyy1000 commented on code in PR #9798:
URL: https://github.com/apache/arrow-datafusion/pull/9798#discussion_r1538061898
##########
datafusion/sql/src/unparser/expr.rs:
##########
@@ -698,17 +733,17 @@ mod tests {
}),
"COUNT(DISTINCT *)",
),
- (Expr::IsNotNull(Box::new(col("a"))), r#""a" IS NOT NULL"#),
+ (col("a").is_not_null(), r#""a" IS NOT NULL"#),
Review Comment:
I also changed some of these tests to make them looks concise.
##########
datafusion/sql/src/unparser/expr.rs:
##########
@@ -113,10 +113,38 @@ impl Unparser<'_> {
}
Expr::Case(Case {
expr,
- when_then_expr: _,
- else_expr: _,
+ when_then_expr,
+ else_expr,
}) => {
- not_impl_err!("Unsupported expression: {expr:?}")
+ let conditions = when_then_expr
+ .iter()
+ .map(|(w, _)| self.expr_to_sql(w))
+ .collect::<Result<Vec<_>>>()?;
+ let results = when_then_expr
+ .iter()
+ .map(|(_, t)| self.expr_to_sql(t))
+ .collect::<Result<Vec<_>>>()?;
Review Comment:
I'm trying to make these two iterations to one, but I failed. ☹️
I tried
1. `unzip`, but I got two vec which consist of `Result<Expr>` but not `Expr`
2. `match`, got type incompatible error 🥲
3. `collect`, but don't know how to collect a `(Result<Expr>, Result<Expr>)`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]