Skip to content

Conversation

@viirya
Copy link
Member

@viirya viirya commented May 30, 2017

What changes were proposed in this pull request?

We changed the parser to reject unaliased subqueries in the FROM clause in SPARK-20690. However, the error message that we now give isn't very helpful:

scala> sql("""SELECT x FROM (SELECT 1 AS x)""")
org.apache.spark.sql.catalyst.parser.ParseException:
mismatched input 'FROM' expecting {<EOF>, 'WHERE', 'GROUP', 'ORDER', 'HAVING', 'LIMIT', 'LATERAL', 'WINDOW', 'UNION', 'EXCEPT', 'MINUS', 'INTERSECT', 'SORT', 'CLUSTER', 'DISTRIBUTE'}(line 1, pos 9)

We should modify the parser to throw a more clear error for such queries:

scala> sql("""SELECT x FROM (SELECT 1 AS x)""")
org.apache.spark.sql.catalyst.parser.ParseException:
The unaliased subqueries in the FROM clause are not supported.(line 1, pos 14)

How was this patch tested?

Modified existing tests to reflect this change.

@viirya
Copy link
Member Author

viirya commented May 30, 2017

@maropu
Copy link
Member

maropu commented May 30, 2017

Better to add tests in SQLQueryTestSuite?

@viirya
Copy link
Member Author

viirya commented May 30, 2017

@maropu Sure. Thanks.

@SparkQA
Copy link

SparkQA commented May 30, 2017

Test build #77521 has started for PR 18141 at commit f64df52.

@SparkQA
Copy link

SparkQA commented May 30, 2017

Test build #77517 has finished for PR 18141 at commit 0a7eab0.

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

@@ -0,0 +1,14 @@
-- Aliased subqueries in FROM clause
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 move the test case sql-tests/inputs/aliased-subquery-in-from.sql to sql-tests/inputs/subquery/subquery-in-from.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.

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.

LGTM except one comment

@SparkQA
Copy link

SparkQA commented May 30, 2017

Test build #77524 has started for PR 18141 at commit 7135bbc.

@viirya
Copy link
Member Author

viirya commented May 30, 2017

retest this please.

@SparkQA
Copy link

SparkQA commented May 30, 2017

Test build #77525 has finished for PR 18141 at commit 7135bbc.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented May 30, 2017

Test build #77528 has finished for PR 18141 at commit cc7c572.

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

@cloud-fan
Copy link
Contributor

LGTM, merging to master!

@asfgit asfgit closed this in 35b644b May 30, 2017
@viirya viirya deleted the SPARK-20916 branch December 27, 2023 18:20
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