alamb commented on a change in pull request #810:
URL: https://github.com/apache/arrow-datafusion/pull/810#discussion_r682046038



##########
File path: datafusion/src/sql/planner.rs
##########
@@ -925,11 +925,40 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
 
     /// Generate a relational expression from a SQL expression
     pub fn sql_to_rex(&self, sql: &SQLExpr, schema: &DFSchema) -> Result<Expr> 
{
-        let expr = self.sql_expr_to_logical_expr(sql, schema)?;
+        let mut expr = self.sql_expr_to_logical_expr(sql, schema)?;
         self.validate_schema_satisfies_exprs(schema, &[expr.clone()])?;
+        expr = self.rewrite_partial_qualifier(expr, schema);
         Ok(expr)
     }
 
+    /// Rewrite aliases which are not-complete (e.g. ones that only include 
only table qualifier in a schema.table qualified relation)
+    fn rewrite_partial_qualifier(&self, expr: Expr, schema: &DFSchema) -> Expr 
{
+        match expr.clone() {

Review comment:
       given you are passing in `expr` here, I wonder if we could remove the 
call to `clone` and save a copy?

##########
File path: datafusion/src/sql/planner.rs
##########
@@ -925,11 +925,40 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
 
     /// Generate a relational expression from a SQL expression
     pub fn sql_to_rex(&self, sql: &SQLExpr, schema: &DFSchema) -> Result<Expr> 
{
-        let expr = self.sql_expr_to_logical_expr(sql, schema)?;
+        let mut expr = self.sql_expr_to_logical_expr(sql, schema)?;
         self.validate_schema_satisfies_exprs(schema, &[expr.clone()])?;
+        expr = self.rewrite_partial_qualifier(expr, schema);

Review comment:
       I wonder if we should do the rewrite prior to calling 
`validate_schema_satisfies_exprs`?




-- 
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]


Reply via email to