alamb commented on code in PR #2344:
URL: https://github.com/apache/arrow-datafusion/pull/2344#discussion_r859653759
##########
datafusion/core/src/sql/planner.rs:
##########
@@ -4182,4 +4264,36 @@ mod tests {
\n TableScan: test projection=None";
quick_test(sql, expected);
}
+
+ #[test]
+ fn exists_subquery() {
+ let sql = "SELECT id FROM person p WHERE EXISTS \
+ (SELECT first_name FROM person \
+ WHERE last_name = p.last_name \
+ AND state = p.state)";
+
+ let expected = "Projection: #p.id\
+ \n Filter: EXISTS (Subquery: Projection: #person.first_name\
+ \n Filter: #person.last_name = #p.last_name AND #person.state =
#p.state\
+ \n TableScan: person projection=None)\
+ \n SubqueryAlias: p\
+ \n TableScan: person projection=None";
+ quick_test(sql, expected);
+ }
+
+ #[test]
+ fn exists_subquery_wildcard() {
+ let sql = "SELECT id FROM person p WHERE EXISTS \
+ (SELECT * FROM person \
+ WHERE last_name = p.last_name \
+ AND state = p.state)";
+
+ let expected = "Projection: #p.id\
+ \n Filter: EXISTS (Subquery: Projection: #person.id,
#person.first_name, #person.last_name, #person.age, #person.state,
#person.salary, #person.birth_date, #person.😀\
+ \n Filter: #person.last_name = #p.last_name AND #person.state =
#p.state\
+ \n TableScan: person projection=None)\
+ \n SubqueryAlias: p\
+ \n TableScan: person projection=None";
Review Comment:
Thank you for the change. It is much easier to see what is going on now.
--
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]