Asura7969 commented on issue #8374:
URL: 
https://github.com/apache/arrow-datafusion/issues/8374#issuecomment-1842402521

   My initial solution:
   ```rust
   .find_map(|(index, (projected_expr, alias))| {
     projected_expr.as_any().downcast_ref::<Column>().and_then(
         |projected_column| {
             (column.index() == projected_column.index()       <--- and index 
comparison
                 && column.name().eq(projected_column.name()))
             .then(|| {
                 state = RewriteState::RewrittenValid;
                 Arc::new(Column::new(alias, index)) as _
             })
         },
     )
   })
   ```
   > and index comparison
   
   ```text
   DataFusion CLI v33.0.0
   ❯ CREATE TABLE users AS VALUES('Alice',50),('Bob',100);
   0 rows in set. Query took 0.022 seconds.
   
   ❯ CREATE TABLE employees AS VALUES('Alice','Finance'),('Bob','Marketing');
   0 rows in set. Query took 0.008 seconds.
   
   ❯ SELECT u.* FROM users u JOIN employees e ON u."column1" = e."column1" 
ORDER BY u."column1", e."column2";
   +---------+---------+
   | column1 | column2 |
   +---------+---------+
   | Alice   | 50      |
   | Bob     | 100     |
   +---------+---------+
   ```
   The result is correct
   


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