Skip to content

Commit

Permalink
fix clippy and support unparsing wildcard
Browse files Browse the repository at this point in the history
  • Loading branch information
goldmedal committed Aug 11, 2024
1 parent 46922f5 commit 55f13e3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion datafusion/expr/src/logical_plan/plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2773,7 +2773,7 @@ fn calc_func_dependencies_for_project(
qualifier: qualifier.clone(),
options: options.clone(),
}],
&input,
input,
)?;
Ok::<_, DataFusionError>(
wildcard_fields
Expand Down
20 changes: 12 additions & 8 deletions datafusion/sql/src/unparser/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ use core::fmt;

use datafusion_expr::ScalarUDF;
use sqlparser::ast::Value::SingleQuotedString;
use sqlparser::ast::{
self, BinaryOperator, Expr as AstExpr, Function, FunctionArg, Ident, Interval,
TimezoneInfo, UnaryOperator,
};
use sqlparser::ast::{self, BinaryOperator, Expr as AstExpr, Function, FunctionArg, Ident, Interval, ObjectName, TimezoneInfo, UnaryOperator};
use std::sync::Arc;
use std::{fmt::Display, vec};

Expand Down Expand Up @@ -482,8 +479,15 @@ impl Unparser<'_> {
format: None,
})
}
Expr::Wildcard { .. } => {
not_impl_err!("Unsupported Expr conversion: {expr:?}")
// TODO: unparsing wildcard addition options
Expr::Wildcard { qualifier, .. } => {
if let Some(qualifier) = qualifier {
let idents: Vec<Ident> = qualifier.to_vec().into_iter().map(|s| Ident::new(s)).collect();
Ok(ast::Expr::QualifiedWildcard(ObjectName(idents)))
}
else {
Ok(ast::Expr::Wildcard)
}
}
Expr::GroupingSet(grouping_set) => match grouping_set {
GroupingSet::GroupingSets(grouping_sets) => {
Expand Down Expand Up @@ -1854,11 +1858,11 @@ mod tests {
(Expr::Negative(Box::new(col("a"))), r#"-a"#),
(
exists(Arc::new(dummy_logical_plan.clone())),
r#"EXISTS (SELECT t.a FROM t WHERE (t.a = 1))"#,
r#"EXISTS (SELECT * FROM t WHERE (t.a = 1))"#,
),
(
not_exists(Arc::new(dummy_logical_plan.clone())),
r#"NOT EXISTS (SELECT t.a FROM t WHERE (t.a = 1))"#,
r#"NOT EXISTS (SELECT * FROM t WHERE (t.a = 1))"#,
),
(
try_cast(col("a"), DataType::Date64),
Expand Down

0 comments on commit 55f13e3

Please sign in to comment.