You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "jiangzhx (via GitHub)" <gi...@apache.org> on 2023/03/31 14:08:31 UTC

[GitHub] [arrow-datafusion] jiangzhx commented on issue #5791: SQL case scalar_subquery logical_paln unexpected Aggregate: groupBy=[[col]]

jiangzhx commented on issue #5791:
URL: https://github.com/apache/arrow-datafusion/issues/5791#issuecomment-1491983864

   @mingmwang  thanks a lot. i'm working on #5686,  i need to cover all count(*) scenarios test case to compare betwen sql and dataframe output same logic plan.
   But I have encountered some challenges now, about using dataframe to generate the same logical plan as SQL
   
   the below dataframe testcase will failed to create physical plan
   ```
   #[tokio::test]
   async fn test_count_wildcard_on_where_scalar_subquery() -> Result<()> {
       let ctx = create_join_context()?;
       ctx.sql("select a,b from t1 where (select count(*) from t2 where t1.a = t2.a)>0;")
           .await?
           .explain(false, false)?
           .show()
           .await?;
   
       let subquery=Expr::ScalarSubquery(datafusion_expr::Subquery {
           subquery: Arc::new(
               ctx.table("t2")
                   .await?
                   .filter( col(Column::from_qualified_name("t1.a")).eq(col("t2.a")))?
                   .aggregate(vec![], vec![count(Wildcard)])?
                   .into_optimized_plan()
                   .unwrap(),
           ),
           outer_ref_columns: vec![],
       }) ;
   
   
       ctx.table("t1")
           .await?
           .filter(
               subquery.gt(lit(ScalarValue::UInt8(Some(0))))
           )?
           .select(vec![col("t1.a"), col("t1.b")])?
           .explain(false, false)?
           .show()
           .await?;
       Ok(())
   }
   
   
   ```


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org