From 310d4f01c029a54ad252361a03f993b97467fda3 Mon Sep 17 00:00:00 2001 From: Jia-Xuan Liu Date: Wed, 18 Dec 2024 22:04:05 +0800 Subject: [PATCH] cargo clippy and fmt --- datafusion/sql/src/unparser/plan.rs | 7 ++----- datafusion/sql/src/unparser/rewrite.rs | 8 +++----- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/datafusion/sql/src/unparser/plan.rs b/datafusion/sql/src/unparser/plan.rs index 4be7e553ef6e..0b4670963724 100644 --- a/datafusion/sql/src/unparser/plan.rs +++ b/datafusion/sql/src/unparser/plan.rs @@ -769,11 +769,8 @@ impl Unparser<'_> { fn is_unnest_placeholder_with_outer_ref(expr: &Expr) -> (bool, bool) { if let Expr::Alias(Alias { expr, .. }) = expr { if let Expr::Column(Column { name, .. }) = expr.as_ref() { - if name.starts_with(UNNEST_PLACEHOLDER) { - return ( - true, - name[UNNEST_PLACEHOLDER.len()..].starts_with("(outer_ref("), - ); + if let Some(prefix) = name.strip_prefix(UNNEST_PLACEHOLDER) { + return (true, prefix.starts_with("(outer_ref(")); } } } diff --git a/datafusion/sql/src/unparser/rewrite.rs b/datafusion/sql/src/unparser/rewrite.rs index 3eccdf48136b..14bbbb22cf86 100644 --- a/datafusion/sql/src/unparser/rewrite.rs +++ b/datafusion/sql/src/unparser/rewrite.rs @@ -295,11 +295,9 @@ pub(super) fn find_unnest_column_alias( if projection.expr.len() != 1 { return (plan, None); } - if let Some(expr) = projection.expr.get(0) { - if let Expr::Alias(alias) = expr { - if alias.expr.schema_name().to_string().starts_with("UNNEST(") { - return (projection.input.as_ref(), Some(alias.name.clone())); - } + if let Some(Expr::Alias(alias)) = projection.expr.first() { + if alias.expr.schema_name().to_string().starts_with("UNNEST(") { + return (projection.input.as_ref(), Some(alias.name.clone())); } } }