Skip to content

Conversation

@dilipbiswal
Copy link
Contributor

@dilipbiswal dilipbiswal commented Jan 26, 2017

What changes were proposed in this pull request?

This PR adds the first set of tests for EXISTS subquery.

File name Brief description
exists-basic.sql Tests EXISTS and NOT EXISTS subqueries with both correlated and local predicates.
exists-within-and-or.sql Tests EXISTS and NOT EXISTS subqueries embedded in AND or OR expression.

DB2 results are attached here as reference :

exists-basic-db2.txt
exists-and-or-db2.txt

How was this patch tested?

This patch is adding tests.

@dilipbiswal dilipbiswal changed the title [SPARK-18872] New test cases for EXISTS subquery [SPARK-18872][SQL][TESTS] New test cases for EXISTS subquery Jan 26, 2017
@dilipbiswal
Copy link
Contributor Author

cc @hvanhovell @gatorsmile @nsyca

emp 2 100.0
emp 2 300.0
emp 3 300.0
emp 4 100.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have compared this result file with the attached DB2 output. The two sets of result are equivalent.

emp 1 10.0
emp 1 20.0
emp 2 100.0
emp 4 100.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have compared this result file with the attached DB2 output. The two sets of result are equivalent.

@SparkQA
Copy link

SparkQA commented Jan 26, 2017

Test build #72029 has finished for PR 16710 at commit 53247fe.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

Copy link
Member

@gatorsmile gatorsmile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did the compare. The results are consistent with the output of DB2.

@gatorsmile
Copy link
Member

LGTM

@gatorsmile
Copy link
Member

Could you update the PR descriptions? Currently, it does not correctly describe the cases you added.

WHERE NOT EXISTS (SELECT *
FROM emp
WHERE emp.emp_name = emp_name
AND bonus_amt > emp.salary);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also add one more test case, which is very like TC.01.08? This test case is used very often in the real world. BTW, you do not need to run DB2. We can know the results using our naked eyes. : )

-- select values present in one table but missing in another one

SELECT emp.*
FROM   emp
WHERE  NOT EXISTS (SELECT NULL
                   FROM   bonus
                   WHERE  bonus.emp_name = emp.emp_name);

Copy link
Contributor Author

@dilipbiswal dilipbiswal Jan 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gatorsmile Thanks .. I have added the suggested test case and have updated the PR description.

@SparkQA
Copy link

SparkQA commented Jan 29, 2017

Test build #72121 has started for PR 16710 at commit 0e93a64.

@dilipbiswal
Copy link
Contributor Author

retest this please

@SparkQA
Copy link

SparkQA commented Jan 29, 2017

Test build #72125 has finished for PR 16710 at commit 0e93a64.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@gatorsmile
Copy link
Member

Thanks! Merging to master.

@asfgit asfgit closed this in e2e7b12 Jan 29, 2017
@dilipbiswal
Copy link
Contributor Author

Thank you very much @gatorsmile

cmonkey pushed a commit to cmonkey/spark that referenced this pull request Feb 15, 2017
## What changes were proposed in this pull request?
This PR adds the first set of tests for EXISTS subquery.

File name                        | Brief description
------------------------| -----------------
exists-basic.sql              |Tests EXISTS and NOT EXISTS subqueries with both correlated and local predicates.
exists-within-and-or.sql|Tests EXISTS and NOT EXISTS subqueries embedded in AND or OR expression.

DB2 results are attached here as reference :

[exists-basic-db2.txt](https://github.com/apache/spark/files/733031/exists-basic-db2.txt)
[exists-and-or-db2.txt](https://github.com/apache/spark/files/733030/exists-and-or-db2.txt)

## How was this patch tested?
This patch is adding tests.

Author: Dilip Biswal <[email protected]>

Closes apache#16710 from dilipbiswal/exist-basic.
asfgit pushed a commit that referenced this pull request Mar 14, 2017
…ll up to Optimizer phase

## What changes were proposed in this pull request?
Currently Analyzer as part of ResolveSubquery, pulls up the correlated predicates to its
originating SubqueryExpression. The subquery plan is then transformed to remove the correlated
predicates after they are moved up to the outer plan. In this PR, the task of pulling up
correlated predicates is deferred to Optimizer. This is the initial work that will allow us to
support the form of correlated subqueries that we don't support today. The design document
from nsyca can be found in the following link :
[DesignDoc](https://docs.google.com/document/d/1QDZ8JwU63RwGFS6KVF54Rjj9ZJyK33d49ZWbjFBaIgU/edit#)

The brief description of code changes (hopefully to aid with code review) can be be found in the
following link:
[CodeChanges](https://docs.google.com/document/d/18mqjhL9V1An-tNta7aVE13HkALRZ5GZ24AATA-Vqqf0/edit#)

## How was this patch tested?
The test case PRs were submitted earlier using.
[16337](#16337) [16759](#16759) [16841](#16841) [16915](#16915) [16798](#16798) [16712](#16712) [16710](#16710) [16760](#16760) [16802](#16802)

Author: Dilip Biswal <[email protected]>

Closes #16954 from dilipbiswal/SPARK-18874.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants