mohammadnaqvi04 commented on code in PR #25008:
URL: https://github.com/apache/datafusion/pull/25008#discussion_r4000393509


##########
datafusion/sqllogictest/test_files/subquery.slt:
##########
@@ -1370,6 +1447,71 @@ where t1_id > 40 or not exists (select 1 from t2 where 
t2.t2_int > t1.t1_int)
 33
 44
 
+# correlated_exists_groupless_count_agg_count_bug_embedded_in_or
+query I rowsort
+select t1_id from t1
+where t1_id > 40 or exists (select count(*) from t2 where t1.t1_id = t2.t2_id 
having count(*) = 0)
+----
+33
+44
+
+# correlated_not_exists_groupless_count_agg_count_bug_embedded_in_or
+query I rowsort
+select t1_id from t1
+where t1_id > 40 or not exists (select count(*) from t2 where t1.t1_id = 
t2.t2_id having count(*) = 0)
+----
+11
+22
+44
+
+# correlated_in_groupless_count_agg_count_bug_embedded_in_or
+query I rowsort
+select t1_id from t1
+where t1_id > 40 or 0 in (select count(*) from t2 where t1.t1_id = t2.t2_id)
+----
+33
+44
+
+# correlated_exists_groupless_null_default_agg_count_bug_embedded_in_or
+query I rowsort
+select t1_id from t1
+where t1_id > 40 or exists (select sum(t2_int) from t2 where t1.t1_id = 
t2.t2_id having sum(t2_int) is null)
+----
+33
+44
+
+# correlated_not_exists_groupless_null_default_agg_count_bug_embedded_in_or
+query I rowsort
+select t1_id from t1
+where t1_id > 40 or not exists (select sum(t2_int) from t2 where t1.t1_id = 
t2.t2_id having sum(t2_int) is null)
+----
+11
+22
+44
+
+# 
correlated_in_groupless_null_default_agg_wrong_zero_substitution_embedded_in_or
+query I rowsort
+select t1_id from t1
+where t1_id > 40 or 0 in (select sum(t2_int) from t2 where t1.t1_id = t2.t2_id)
+----
+44
+
+# correlated_not_in_groupless_count_agg_count_bug_embedded_in_or
+query I rowsort
+select t1_id from t1
+where t1_id > 40 or 0 not in (select count(*) from t2 where t1.t1_id = 
t2.t2_id having count(*) = 0)
+----
+44

Review Comment:
   Fixed both in followup.
   
   ```
   > SELECT t1_id, t1_int FROM t1 WHERE 0 NOT IN (SELECT count(*) FROM t2 WHERE 
t1.t1_id = t2.t2_id HAVING count(*) = 0);
   
   +-------+--------+
   | t1_id | t1_int |
   +-------+--------+
   | 11    | 1      |
   | 22    | 2      |
   | 44    | 4      |
   +-------+--------+
   3 row(s) fetched.
   Elapsed 0.018 seconds.
   
   > select t1_id from t1 where t1_id > 40 or 0 not in (select count(*) from t2 
where t1.t1_id = t2.t2_id having count(*) = 0);
   
   +-------+
   | t1_id |
   +-------+
   | 11    |
   | 22    |
   | 44    |
   +-------+
   3 row(s) fetched.
   Elapsed 0.011 seconds.
   ```



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