notfilippo commented on issue #17405:
URL: https://github.com/apache/datafusion/issues/17405#issuecomment-3254296118

   I have a much better repro for the optimizer fail which does not involve 
substrait:
   
   ```rust
   #[tokio::test]
   async fn subquery_alias_confusing_the_optimizer() -> Result<()> {
       let state = make_session_state();
   
       let schema = Schema::new(vec![Field::new("a", DataType::Int32, false)]);
   
       let left = table_scan(Some("left"), &schema, None)?;
       let right = table_scan(Some("right"), &schema, None)?.build()?;
   
       let join_keys = (
           vec![datafusion_common::Column::new(Some("left"), "a")],
           vec![datafusion_common::Column::new(Some("right"), "a")],
       );
   
       let join = left
           .join(right, JoinType::Full, join_keys, None)?
           .build()?;
   
       let alias = subquery_alias(join, "alias")?;
   
       let logical_plan = LogicalPlanBuilder::new(alias)
           .project(vec![col("a:1")])?
           .build()?;
   
       eprintln!("{}", logical_plan);
   
       let optimized_logical_plan = state.optimize(&logical_plan)?; // <- fails 
here
   
       eprintln!("{}", optimized_logical_plan);
   
       // let planner = DefaultPhysicalPlanner::default();
       // let physical_plan = planner.create_physical_plan(&optimized_plan, 
&state).await?;
       // eprintln!("{}", physical_plan);
   
       Ok(())
   }
   ```
   
   The first `eprintln` outputs:
   
   ```
   Projection: alias.a:1
     SubqueryAlias: alias
       Full Join: left.a = right.a
         TableScan: left
         TableScan: right
   ```


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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to