You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "Hisoka-X (via GitHub)" <gi...@apache.org> on 2023/04/17 13:24:36 UTC

[GitHub] [spark] Hisoka-X opened a new pull request, #40823: [SPARK-42552][SQL] Fix select without parentheses can't be parsed

Hisoka-X opened a new pull request, #40823:
URL: https://github.com/apache/spark/pull/40823

   <!--
   Thanks for sending a pull request!  Here are some tips for you:
     1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
     2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
     3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
     4. Be sure to keep the PR description updated to reflect all changes.
     5. Please write your PR title to summarize what this PR proposes.
     6. If possible, provide a concise example to reproduce the issue for a faster review.
     7. If you want to add a new configuration, please read the guideline first for naming configurations in
        'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
     8. If you want to add or modify an error type or message, please read the guideline first in
        'core/src/main/resources/error/README.md'.
   -->
   
   ### What changes were proposed in this pull request?
   Fix sql parser throw `ParseException` in `SSL` mode will not try `LL` mode.
   <!--
   Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue. 
   If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
     1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
     2. If you fix some SQL features, you can provide some references of other DBMSes.
     3. If there is design documentation, please add the link.
     4. If there is a discussion in the mailing list, please add the link.
   -->
   
   
   ### Why are the changes needed?
   Make some special sql can be parsed. Like `SELECT 1 UNION SELECT 1`.
   <!--
   Please clarify why the changes are needed. For instance,
     1. If you propose a new API, clarify the use case for a new API.
     2. If you fix a bug, you can clarify why it is a bug.
   -->
   
   
   ### Does this PR introduce _any_ user-facing change?
   No
   <!--
   Note that it means *any* user-facing change including all aspects such as the documentation fix.
   If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
   If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
   If no, write 'No'.
   -->
   
   
   ### How was this patch tested?
   Add new test
   <!--
   If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
   If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
   If tests were not added, please describe why they were not added and/or why it was difficult to add.
   If benchmark tests were added, please run the benchmarks in GitHub Actions for the consistent environment, and the instructions could accord to: https://spark.apache.org/developer-tools.html#github-workflow-benchmarks.
   -->
   


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] pan3793 commented on a diff in pull request #40823: [SPARK-42552][SQL] Fix select without parentheses can't be parsed

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #40823:
URL: https://github.com/apache/spark/pull/40823#discussion_r1168788733


##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/parser/PlanParserSuite.scala:
##########
@@ -197,6 +197,12 @@ class PlanParserSuite extends AnalysisTest {
       parameters = Map.empty)
   }
 
+  test("select and union without parentheses") {
+    val plan = Distinct(OneRowRelation().select(Literal(1))
+      .union(OneRowRelation().select(Literal(1))))
+    assertEqual("select 1 union select 1", plan)

Review Comment:
   Have done a quick check w/ the following change
   
   ```patch
   - parser.setErrorHandler(new SparkParserErrorStrategy())
   + parser.setErrorHandler(new BailErrorStrategy())
   ```
   
   ```
   sbt:spark-catalyst> testOnly *PlanParserSuite -- -z "select and union without parentheses"
   [warn] multiple main classes detected: run 'show discoveredMainClasses' to see the list
   [info] compiling 1 Scala source to /Users/chengpan/Projects/apache-spark/sql/catalyst/target/scala-2.12/classes ...
   [info] PlanParserSuite:
   [info] - select and union without parentheses (364 milliseconds)
   [info] Run completed in 1 second, 463 milliseconds.
   [info] Total number of tests run: 1
   [info] Suites: completed 1, aborted 0
   [info] Tests: succeeded 1, failed 0, canceled 0, ignored 0, pending 0
   [info] All tests passed.
   [success] Total time: 31 s, completed Apr 17, 2023 10:05:54 PM
   ```



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] pan3793 commented on a diff in pull request #40823: [SPARK-42552][SQL] Fix select without parentheses can't be parsed

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #40823:
URL: https://github.com/apache/spark/pull/40823#discussion_r1169585440


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/ParseDriver.scala:
##########
@@ -127,7 +127,7 @@ abstract class AbstractSqlParser extends ParserInterface with SQLConfHelper with
         toResult(parser)
       }
       catch {
-        case e: ParseCancellationException =>
+        case _: ParseCancellationException | _: ParseException =>

Review Comment:
   @Hisoka-X @cloud-fan I think we should provide two `ErrorStrategy`s
   ```
   class SparkParserBailErrorStrategy() extends BailErrorStrategy
   class SparkParserDefaultErrorStrategy() extends DefaultErrorStrategy
   ```
   
   and following the https://github.com/antlr/antlr4/issues/192#issuecomment-15238595 to implement the "two-stage parsing strategy"



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] pan3793 commented on a diff in pull request #40823: [SPARK-42552][SQL] Fix select without parentheses can't be parsed

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #40823:
URL: https://github.com/apache/spark/pull/40823#discussion_r1168786863


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/ParseDriver.scala:
##########
@@ -127,7 +127,7 @@ abstract class AbstractSqlParser extends ParserInterface with SQLConfHelper with
         toResult(parser)
       }
       catch {
-        case e: ParseCancellationException =>
+        case _: ParseCancellationException | _: ParseException =>

Review Comment:
   This fix looks too broad.
   
   Have done some investigations, the key point should be to use `BailErrorStrategy`.
   
   This should be a long-standing issue, before SPARK-38385, Spark uses `DefaultErrorStrategy`, and after SPARK-38385 Spark uses `class SparkParserErrorStrategy() extends DefaultErrorStrategy`.
   
   So this is not the correct implementation of the "two-stage parsing strategy" 
   
   https://github.com/antlr/antlr4/issues/192#issuecomment-15238595
   



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] Hisoka-X commented on a diff in pull request #40823: [SPARK-42552][SQL] Fix select without parentheses can't be parsed

Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #40823:
URL: https://github.com/apache/spark/pull/40823#discussion_r1168891859


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/ParseDriver.scala:
##########
@@ -127,7 +127,7 @@ abstract class AbstractSqlParser extends ParserInterface with SQLConfHelper with
         toResult(parser)
       }
       catch {
-        case e: ParseCancellationException =>
+        case _: ParseCancellationException | _: ParseException =>

Review Comment:
   Thanks for remind. The `SparkParserErrorStrategy` will rewrap Exception which throw by antlr4. And finally throw it by `ParseException`. So if we want to fix this, catch `ParserException` will be a way. If you have any better idea please let me know. Thanks!



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] Hisoka-X commented on a diff in pull request #40823: [SPARK-42552][SQL] Fix select without parentheses can't be parsed

Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #40823:
URL: https://github.com/apache/spark/pull/40823#discussion_r1168894050


##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/parser/PlanParserSuite.scala:
##########
@@ -197,6 +197,12 @@ class PlanParserSuite extends AnalysisTest {
       parameters = Map.empty)
   }
 
+  test("SPARK-42552: select and union without parentheses") {

Review Comment:
   Thanks for remind. Changed.



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] Hisoka-X commented on pull request #40823: [SPARK-42552][SQL] Fix select without parentheses can't be parsed

Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on PR #40823:
URL: https://github.com/apache/spark/pull/40823#issuecomment-1513061680

   Replace by https://github.com/apache/spark/pull/40835


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] Hisoka-X commented on pull request #40823: [SPARK-42552][SQL] Fix select without parentheses can't be parsed

Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on PR #40823:
URL: https://github.com/apache/spark/pull/40823#issuecomment-1512553285

   > Can you provide more background to help people understand and review? I have no idea why catching one more exception type can fix this parser issue.
   
   Thanks for point that. I updated the description.


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] pan3793 commented on a diff in pull request #40823: [SPARK-42552][SQL] Fix select without parentheses can't be parsed

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #40823:
URL: https://github.com/apache/spark/pull/40823#discussion_r1169756827


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/ParseDriver.scala:
##########
@@ -127,7 +127,7 @@ abstract class AbstractSqlParser extends ParserInterface with SQLConfHelper with
         toResult(parser)
       }
       catch {
-        case e: ParseCancellationException =>
+        case _: ParseCancellationException | _: ParseException =>

Review Comment:
   opened https://github.com/apache/spark/pull/40835 to implement my idea.



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] HyukjinKwon commented on pull request #40823: [SPARK-42552][SQL] Fix select without parentheses can't be parsed

Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on PR #40823:
URL: https://github.com/apache/spark/pull/40823#issuecomment-1512395349

   cc @MaxGekk and @gengliangwang FYI


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] Hisoka-X commented on a diff in pull request #40823: [SPARK-42552][SQL] Fix select without parentheses can't be parsed

Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #40823:
URL: https://github.com/apache/spark/pull/40823#discussion_r1169595889


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/ParseDriver.scala:
##########
@@ -127,7 +127,7 @@ abstract class AbstractSqlParser extends ParserInterface with SQLConfHelper with
         toResult(parser)
       }
       catch {
-        case e: ParseCancellationException =>
+        case _: ParseCancellationException | _: ParseException =>

Review Comment:
   > @Hisoka-X @cloud-fan I think we should provide two `ErrorStrategy`s
   > 
   > ```
   > class SparkParserBailErrorStrategy() extends BailErrorStrategy
   > class SparkParserDefaultErrorStrategy() extends DefaultErrorStrategy
   > ```
   > 
   > and follow the [antlr/antlr4#192 (comment)](https://github.com/antlr/antlr4/issues/192#issuecomment-15238595) to implement the "two-stage parsing strategy"
   
   I'm not sure this way will be worked. The main reason for custom `ErrorStrategy` are replace anltr4 Exception by some Spark Exception. So we also need catch the Spark Exception.



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] cloud-fan commented on pull request #40823: [SPARK-42552][SQL] Fix select without parentheses can't be parsed

Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on PR #40823:
URL: https://github.com/apache/spark/pull/40823#issuecomment-1512499213

   Can you provide more background to help people understand and review? I have no idea why catching one more exception type can fix this parser issue.


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] LuciferYang commented on a diff in pull request #40823: [SPARK-42552][SQL] Fix select without parentheses can't be parsed

Posted by "LuciferYang (via GitHub)" <gi...@apache.org>.
LuciferYang commented on code in PR #40823:
URL: https://github.com/apache/spark/pull/40823#discussion_r1168782700


##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/parser/PlanParserSuite.scala:
##########
@@ -197,6 +197,12 @@ class PlanParserSuite extends AnalysisTest {
       parameters = Map.empty)
   }
 
+  test("select and union without parentheses") {

Review Comment:
   ```suggestion
     test("SPARK-42552: select and union without parentheses") {
   ```



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] cloud-fan commented on a diff in pull request #40823: [SPARK-42552][SQL] Fix select without parentheses can't be parsed

Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on code in PR #40823:
URL: https://github.com/apache/spark/pull/40823#discussion_r1169702432


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/ParseDriver.scala:
##########
@@ -127,7 +127,7 @@ abstract class AbstractSqlParser extends ParserInterface with SQLConfHelper with
         toResult(parser)
       }
       catch {
-        case e: ParseCancellationException =>
+        case _: ParseCancellationException | _: ParseException =>

Review Comment:
   @pan3793 can you make a PR to implement your idea and see if it works?



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] pan3793 commented on a diff in pull request #40823: [SPARK-42552][SQL] Fix select without parentheses can't be parsed

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #40823:
URL: https://github.com/apache/spark/pull/40823#discussion_r1168786863


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/ParseDriver.scala:
##########
@@ -127,7 +127,7 @@ abstract class AbstractSqlParser extends ParserInterface with SQLConfHelper with
         toResult(parser)
       }
       catch {
-        case e: ParseCancellationException =>
+        case _: ParseCancellationException | _: ParseException =>

Review Comment:
   This fix looks too broad.
   
   Have done some investigations, the key point should be to use `BailErrorStrategy`.
   
   This should be a long-standing issue, before SPARK-38385, Spark uses `DefaultErrorStrategy`, and after SPARK-38385 Spark uses `class SparkParserErrorStrategy() extends DefaultErrorStrategy`.
   
   So this is not a correct implementation of the "two-stage parsing strategy" 
   
   https://github.com/antlr/antlr4/issues/192#issuecomment-15238595
   



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] pan3793 commented on a diff in pull request #40823: [SPARK-42552][SQL] Fix select without parentheses can't be parsed

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #40823:
URL: https://github.com/apache/spark/pull/40823#discussion_r1169585440


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/ParseDriver.scala:
##########
@@ -127,7 +127,7 @@ abstract class AbstractSqlParser extends ParserInterface with SQLConfHelper with
         toResult(parser)
       }
       catch {
-        case e: ParseCancellationException =>
+        case _: ParseCancellationException | _: ParseException =>

Review Comment:
   @Hisoka-X @cloud-fan I think we should provide two `ErrorStrategy`s
   ```
   class SparkParserBailErrorStrategy() extends BailErrorStrategy
   class SparkParserDefaultErrorStrategy() extends DefaultErrorStrategy
   ```
   
   and follow the https://github.com/antlr/antlr4/issues/192#issuecomment-15238595 to implement the "two-stage parsing strategy"



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] LuciferYang commented on pull request #40823: [SPARK-42552][SQL] Fix select without parentheses can't be parsed

Posted by "LuciferYang (via GitHub)" <gi...@apache.org>.
LuciferYang commented on PR #40823:
URL: https://github.com/apache/spark/pull/40823#issuecomment-1511463799

   > Make some special sql can be parsed. Like SELECT 1 UNION SELECT 1.
   
   cc @wangyum FYI


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] wangyum commented on a diff in pull request #40823: [SPARK-42552][SQL] Fix select without parentheses can't be parsed

Posted by "wangyum (via GitHub)" <gi...@apache.org>.
wangyum commented on code in PR #40823:
URL: https://github.com/apache/spark/pull/40823#discussion_r1168888063


##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/parser/PlanParserSuite.scala:
##########
@@ -197,6 +197,12 @@ class PlanParserSuite extends AnalysisTest {
       parameters = Map.empty)
   }
 
+  test("SPARK-42552: select and union without parentheses") {

Review Comment:
   Could we do not insert this test between `unclosed bracketed comment` related tests?



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] Hisoka-X commented on a diff in pull request #40823: [SPARK-42552][SQL] Fix select without parentheses can't be parsed

Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #40823:
URL: https://github.com/apache/spark/pull/40823#discussion_r1169595889


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/ParseDriver.scala:
##########
@@ -127,7 +127,7 @@ abstract class AbstractSqlParser extends ParserInterface with SQLConfHelper with
         toResult(parser)
       }
       catch {
-        case e: ParseCancellationException =>
+        case _: ParseCancellationException | _: ParseException =>

Review Comment:
   > @Hisoka-X @cloud-fan I think we should provide two `ErrorStrategy`s
   > 
   > ```
   > class SparkParserBailErrorStrategy() extends BailErrorStrategy
   > class SparkParserDefaultErrorStrategy() extends DefaultErrorStrategy
   > ```
   > 
   > and follow the [antlr/antlr4#192 (comment)](https://github.com/antlr/antlr4/issues/192#issuecomment-15238595) to implement the "two-stage parsing strategy"
   
   I'm not sure this way will be worked. The main reason for custom `ErrorStrategy` are replace anltr4 Exception by some Spark Exception. So we need catch the Spark Exception too.



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] Hisoka-X closed pull request #40823: [SPARK-42552][SQL] Fix select without parentheses can't be parsed

Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X closed pull request #40823: [SPARK-42552][SQL] Fix select without parentheses can't be parsed
URL: https://github.com/apache/spark/pull/40823


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org