jayzhan211 commented on code in PR #14927:
URL: https://github.com/apache/datafusion/pull/14927#discussion_r1974873043


##########
datafusion/sqllogictest/test_files/subquery.slt:
##########
@@ -1393,3 +1393,37 @@ item1 1970-01-01T00:00:03 75
 
 statement ok
 drop table source_table;
+
+# test count wildcard
+statement count 0
+create table t1(a int) as values (1);
+
+statement count 0
+create table t2(b int) as values (1);
+
+query I
+SELECT a FROM t1 WHERE EXISTS (SELECT count(*) FROM t2)
+----
+1
+
+query TT
+explain SELECT a FROM t1 WHERE EXISTS (SELECT count(*) FROM t2)
+----
+logical_plan
+01)LeftSemi Join: 
+02)--TableScan: t1 projection=[a]
+03)--SubqueryAlias: __correlated_sq_1
+04)----Projection: 
+05)------Aggregate: groupBy=[[]], aggr=[[count(Int64(1))]]
+06)--------TableScan: t2 projection=[]

Review Comment:
   ```
   [2025-02-28T06:22:26Z DEBUG datafusion_optimizer::utils] 
simplify_expressions:
       Projection: t1.a
         LeftSemi Join: 
           Filter: Boolean(true)
             TableScan: t1
           SubqueryAlias: __correlated_sq_1
             Projection: count(Int64(1)) AS count(*)
               Aggregate: groupBy=[[]], aggr=[[count(Int64(1))]]
                 TableScan: t2
       
   [2025-02-28T06:22:26Z DEBUG datafusion_optimizer::optimizer] Plan unchanged 
by optimizer rule 'unwrap_cast_in_comparison' (pass 0)
   [2025-02-28T06:22:26Z DEBUG datafusion_optimizer::optimizer] Plan unchanged 
by optimizer rule 'common_sub_expression_eliminate' (pass 0)
   [2025-02-28T06:22:26Z DEBUG datafusion_optimizer::optimizer] Plan unchanged 
by optimizer rule 'eliminate_group_by_constant' (pass 0)
   [2025-02-28T06:22:26Z DEBUG datafusion_optimizer::utils] 
optimize_projections:
       LeftSemi Join: 
         Filter: Boolean(true)
           TableScan: t1 projection=[a]
         SubqueryAlias: __correlated_sq_1
           Projection: 
             Aggregate: groupBy=[[]], aggr=[[count(Int64(1))]]
               TableScan: t2 projection=[]
   ```



-- 
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-unsubscr...@datafusion.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to