This is an automated email from the ASF dual-hosted git repository.
jonah pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git
The following commit(s) were added to refs/heads/main by this push:
new cfe05b85cf improve the condition checking for unparsing table_scan
(#13062)
cfe05b85cf is described below
commit cfe05b85cf75e5b0ddd7bd866ddca48b2de16738
Author: Jax Liu <[email protected]>
AuthorDate: Wed Oct 23 14:24:14 2024 +0800
improve the condition checking for unparsing table_scan (#13062)
* improve the condition check
* fix tests
* remove unnecessary clone
---
datafusion/sql/src/unparser/plan.rs | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/datafusion/sql/src/unparser/plan.rs
b/datafusion/sql/src/unparser/plan.rs
index 77f885c1de..037748035f 100644
--- a/datafusion/sql/src/unparser/plan.rs
+++ b/datafusion/sql/src/unparser/plan.rs
@@ -677,10 +677,10 @@ impl Unparser<'_> {
//
// Example:
// select t1.c1 from t1 where t1.c1 > 1 -> select a.c1 from
t1 as a where a.c1 > 1
- if alias.is_some()
- && (table_scan.projection.is_some() ||
!table_scan.filters.is_empty())
- {
- builder = builder.alias(alias.clone().unwrap())?;
+ if let Some(ref alias) = alias {
+ if table_scan.projection.is_some() ||
!table_scan.filters.is_empty() {
+ builder = builder.alias(alias.clone())?;
+ }
}
if let Some(project_vec) = &table_scan.projection {
@@ -733,10 +733,10 @@ impl Unparser<'_> {
// So we will append the alias to this subquery.
// Example:
// select * from t1 limit 10 -> (select * from t1 limit 10)
as a
- if alias.is_some()
- && (table_scan.projection.is_none() &&
table_scan.filters.is_empty())
- {
- builder = builder.alias(alias.clone().unwrap())?;
+ if let Some(alias) = alias {
+ if table_scan.projection.is_none() &&
table_scan.filters.is_empty() {
+ builder = builder.alias(alias)?;
+ }
}
Ok(Some(builder.build()?))
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]