Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-13603] [SQL] support SQL generation for subquery #11453

Closed
wants to merge 3 commits into from

Conversation

davies
Copy link
Contributor

@davies davies commented Mar 1, 2016

What changes were proposed in this pull request?

This is support SQL generation for subquery expressions, which will be replaced to a SubqueryHolder inside SQLBuilder recursively.

How was this patch tested?

Added unit tests.

@SparkQA
Copy link

SparkQA commented Mar 1, 2016

Test build #52264 has finished for PR 11453 at commit 9876ffc.

  • This patch fails Scala style tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
    • case class SubqueryHolder(query: String) extends LeafExpression with Unevaluable

@SparkQA
Copy link

SparkQA commented Mar 2, 2016

Test build #52267 has finished for PR 11453 at commit efa545f.

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


test("subquery") {
checkSqlGeneration("SELECT 1 + (SELECT 2)")
checkSqlGeneration("SELECT 1 + (SELECT 2 + (SELECT 3 as a))")
Copy link
Member

Choose a reason for hiding this comment

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

Could we add more test cases?

SELECT * from (SELECT 1 + (SELECT 2 + (SELECT 3 as a)) t

If we run this, we hit a bug in Scalar Subquery support. If you want, I can try to fix it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will look into it, thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You missed a ) here.

I don't think this is a good test case for this suite. (it works by the way)

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, my fault. : )

How about moving a few typical scalar queries in SubquerySuite to this test suite?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not necessary, different test suite for different purpose, we should not repeat every test cases everywhere.

@davies
Copy link
Contributor Author

davies commented Mar 2, 2016

cc @liancheng

Conflicts:
	sql/hive/src/main/scala/org/apache/spark/sql/hive/SQLBuilder.scala
@SparkQA
Copy link

SparkQA commented Mar 4, 2016

Test build #52443 has finished for PR 11453 at commit 5fbc714.

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

@liancheng
Copy link
Contributor

LGTM, merged to master. Thanks!

@asfgit asfgit closed this in dd83c20 Mar 4, 2016
roygao94 pushed a commit to roygao94/spark that referenced this pull request Mar 22, 2016
## What changes were proposed in this pull request?

This is support SQL generation for subquery expressions, which will be replaced to a SubqueryHolder inside SQLBuilder recursively.

## How was this patch tested?

Added unit tests.

Author: Davies Liu <davies@databricks.com>

Closes apache#11453 from davies/sql_subquery.
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