Skip to content

Conversation

@dongjoon-hyun
Copy link
Member

What changes were proposed in this pull request?

Currently, SQLBuilder raises empty.reduceLeft exceptions on unoptimized EXISTS queries. We had better prevent this.

scala> sql("CREATE TABLE t1(a int)")
scala> val df = sql("select * from t1 b where exists (select * from t1 a)")
scala> new org.apache.spark.sql.catalyst.SQLBuilder(df).toSQL
java.lang.UnsupportedOperationException: empty.reduceLeft

How was this patch tested?

Pass the Jenkins tests with a new test suite.

@SparkQA
Copy link

SparkQA commented Jul 21, 2016

Test build #62689 has finished for PR 14307 at commit 7baab5e.

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

@dongjoon-hyun
Copy link
Member Author

Hi, @hvanhovell .
Could you review this PR about SQLBuilder?

@jaceklaskowski
Copy link
Contributor

I didn't even know such a SQL query is possible in SQL :) Lots to learn still.

Copy link
Contributor

Choose a reason for hiding this comment

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

LogicalPlanToSQLSuite?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, I see.

@SparkQA
Copy link

SparkQA commented Jul 23, 2016

Test build #62756 has finished for PR 14307 at commit 70f5401.

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

@dongjoon-hyun
Copy link
Member Author

Rebased.

@dongjoon-hyun
Copy link
Member Author

Hi, @hvanhovell .
Could you review this PR?

Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: it is a little more readable if we move the addSubqueryIfNeeded(query) out of the if...else... and into a separate variable.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, right. I'll fix soon.

@hvanhovell
Copy link
Contributor

One minor comment. Looks pretty good.

@dongjoon-hyun
Copy link
Member Author

Thank you for review, @hvanhovell .
I updated that.

@hvanhovell
Copy link
Contributor

LGMT, pending jenkins

@SparkQA
Copy link

SparkQA commented Jul 25, 2016

Test build #62815 has finished for PR 14307 at commit 3d8dbbd.

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

@dongjoon-hyun
Copy link
Member Author

It's strange . Jenkins does not trigger the test for the last commit.

@dongjoon-hyun
Copy link
Member Author

Oh, it became a maintenance mode. :(

@SparkQA
Copy link

SparkQA commented Jul 25, 2016

Test build #62820 has finished for PR 14307 at commit 7c7b58e.

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

@dongjoon-hyun
Copy link
Member Author

Hi, @hvanhovell .
Could you merge this PR? :)

Copy link
Contributor

Choose a reason for hiding this comment

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

it'd be good to test the generated sql.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure. No problem.

@dongjoon-hyun
Copy link
Member Author

Hi, @rxin .
The PR is updated to use checkSQL.

@SparkQA
Copy link

SparkQA commented Jul 25, 2016

Test build #62828 has finished for PR 14307 at commit be2085a.

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

@dongjoon-hyun
Copy link
Member Author

Hi, @rxin .
Could you merge this PR please?
Since this PR uses checkSQL, it will conflict with Generate stable SQLs in SQLBuilder(#14257)
After merging this, I will rebase to the master and regenerate the answer in #14257.

@rxin
Copy link
Contributor

rxin commented Jul 26, 2016

Merging in master/2.0.

asfgit pushed a commit that referenced this pull request Jul 26, 2016
…ueries

## What changes were proposed in this pull request?

Currently, `SQLBuilder` raises `empty.reduceLeft` exceptions on *unoptimized* `EXISTS` queries. We had better prevent this.
```scala
scala> sql("CREATE TABLE t1(a int)")
scala> val df = sql("select * from t1 b where exists (select * from t1 a)")
scala> new org.apache.spark.sql.catalyst.SQLBuilder(df).toSQL
java.lang.UnsupportedOperationException: empty.reduceLeft
```

## How was this patch tested?

Pass the Jenkins tests with a new test suite.

Author: Dongjoon Hyun <dongjoon@apache.org>

Closes #14307 from dongjoon-hyun/SPARK-16672.

(cherry picked from commit 8a8d26f)
Signed-off-by: Reynold Xin <rxin@databricks.com>
@dongjoon-hyun
Copy link
Member Author

Thank you so much for review and merging, @rxin , @hvanhovell , and @jaceklaskowski !

@asfgit asfgit closed this in 8a8d26f Jul 26, 2016
@dongjoon-hyun dongjoon-hyun deleted the SPARK-16672 branch August 14, 2016 09:45
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.

5 participants