jiangzhx opened a new issue, #5771:
URL: https://github.com/apache/arrow-datafusion/issues/5771

   ### Describe the bug
   
   filter with exists subquery,TableScan node added a unexpected projection
   
           
"+--------------+-------------------------------------------------------+",
           "| plan_type    | plan                                               
   |",
           
"+--------------+-------------------------------------------------------+",
           "| logical_plan | Filter: EXISTS (<subquery>)                        
   |",
           "|              |   Subquery:                                        
   |",
           "|              |     Aggregate: groupBy=[[]], 
aggr=[[COUNT(UInt8(1))]] |",
           "|              |       TableScan: t2 projection=[a]                 
   |",
           "|              |   TableScan: t1 projection=[a, b]                  
   |",
           
"+--------------+-------------------------------------------------------+",
   
   
   ### To Reproduce
   
   ```
   
   #[tokio::test]
   async fn test_count_wildcard_on_where_exist() -> Result<()> {
       let ctx = create_join_context()?;
   
       let df_results = ctx
           .table("t1")
           .await?
           .filter(Expr::Exists {
               subquery: Subquery {
                   subquery: Arc::new(
                       ctx.table("t2")
                           .await?
                           .aggregate(vec![], vec![count(Expr::Wildcard)])?
                           .select(vec![count(Expr::Wildcard)])?
                           .into_optimized_plan()?,
                   ),
                   outer_ref_columns: vec![],
               },
               negated: false,
           })?
           .select(vec![col("a"), col("b")])?
           .explain(false, false)?
           .collect()
           .await?;
       #[rustfmt::skip]
           let expected = vec![
           
"+--------------+-------------------------------------------------------+",
           "| plan_type    | plan                                               
   |",
           
"+--------------+-------------------------------------------------------+",
           "| logical_plan | Filter: EXISTS (<subquery>)                        
   |",
           "|              |   Subquery:                                        
   |",
           "|              |     Aggregate: groupBy=[[]], 
aggr=[[COUNT(UInt8(1))]] |",
           "|              |       TableScan: t2 projection=[a]                 
   |",
           "|              |   TableScan: t1 projection=[a, b]                  
   |",
           
"+--------------+-------------------------------------------------------+",
       ];
       assert_batches_eq!(expected, &df_results);
       Ok(())
   }
   
   ```
   
   ### Expected behavior
   
   _No response_
   
   ### Additional context
   
   _No response_


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