-
Notifications
You must be signed in to change notification settings - Fork 28.2k
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-30049][SQL] SQL fails to parse when comment contains an unmatched quote character. #27321
Conversation
ok to test |
Test build #117249 has finished for PR 27321 at commit
|
cc @wangyum FYI |
I haven't had time to test your patch but did you test this with just the spark-shell and spark.sql(""" """) syntax as well? I didn't think that went through the SparkSQLCliDriver and that case also fails. |
ping @javierivanov |
Sorry for my delay here...
In this case the
The SQLDriver is parsing SQLStatements into a list, and foreach calls the sql context to interpret each. This was failing because the parser was still detecting quotes inside of comments and passed the sql statement like this:
Let me know for any comments 👍 |
yea, right. Spark doesnt support multi-line queries in |
...e-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkSQLCLIDriver.scala
Outdated
Show resolved
Hide resolved
|;""".stripMargin -> "testcomment" | ||
) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Can you avoid this unnecessary blank?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maropu Not sure, which blank?
sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/CliSuite.scala
Show resolved
Hide resolved
...e-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkSQLCLIDriver.scala
Outdated
Show resolved
Hide resolved
ah ok, that makes sense, thanks |
Test build #117997 has finished for PR 27321 at commit
|
ping @wangyum |
sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/CliSuite.scala
Outdated
Show resolved
Hide resolved
sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/CliSuite.scala
Outdated
Show resolved
Hide resolved
...e-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkSQLCLIDriver.scala
Outdated
Show resolved
Hide resolved
...e-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkSQLCLIDriver.scala
Outdated
Show resolved
Hide resolved
Test build #118967 has finished for PR 27321 at commit
|
@wangyum any comments? |
…hed quote character ### What changes were proposed in this pull request? A SQL statement that contains a comment with an unmatched quote character can lead to a parse error: - Added a insideComment flag in the splitter method to avoid checking single and double quotes within a comment: ``` spark-sql> SELECT 1 -- someone's comment here > ; Error in query: extraneous input ';' expecting <EOF>(line 2, pos 0) == SQL == SELECT 1 -- someone's comment here ; ^^^ ``` ### Why are the changes needed? This misbehaviour was not present on previous spark versions. ### Does this PR introduce any user-facing change? - No ### How was this patch tested? - New tests were added. Closes #27321 from javierivanov/SPARK-30049B. Lead-authored-by: Javier <jfuentes@hortonworks.com> Co-authored-by: Javier Fuentes <j.fuentes.m@icloud.com> Signed-off-by: Thomas Graves <tgraves@apache.org> (cherry picked from commit 3ff2135) Signed-off-by: Thomas Graves <tgraves@apache.org>
merged to master and branch-3.0, thanks @javierivanov |
Hi, All. |
…hed quote character ### What changes were proposed in this pull request? A SQL statement that contains a comment with an unmatched quote character can lead to a parse error: - Added a insideComment flag in the splitter method to avoid checking single and double quotes within a comment: ``` spark-sql> SELECT 1 -- someone's comment here > ; Error in query: extraneous input ';' expecting <EOF>(line 2, pos 0) == SQL == SELECT 1 -- someone's comment here ; ^^^ ``` ### Why are the changes needed? This misbehaviour was not present on previous spark versions. ### Does this PR introduce any user-facing change? - No ### How was this patch tested? - New tests were added. Closes apache#27321 from javierivanov/SPARK-30049B. Lead-authored-by: Javier <jfuentes@hortonworks.com> Co-authored-by: Javier Fuentes <j.fuentes.m@icloud.com> Signed-off-by: Thomas Graves <tgraves@apache.org>
…hed quote character A SQL statement that contains a comment with an unmatched quote character can lead to a parse error: - Added a insideComment flag in the splitter method to avoid checking single and double quotes within a comment: ``` spark-sql> SELECT 1 -- someone's comment here > ; Error in query: extraneous input ';' expecting <EOF>(line 2, pos 0) == SQL == SELECT 1 -- someone's comment here ; ^^^ ``` This misbehaviour was not present on previous spark versions. - No - New tests were added. Closes apache#27321 from javierivanov/SPARK-30049B. Lead-authored-by: Javier <jfuentes@hortonworks.com> Co-authored-by: Javier Fuentes <j.fuentes.m@icloud.com> Signed-off-by: Thomas Graves <tgraves@apache.org>
What changes were proposed in this pull request?
A SQL statement that contains a comment with an unmatched quote character can lead to a parse error:
Why are the changes needed?
This misbehaviour was not present on previous spark versions.
Does this PR introduce any user-facing change?
How was this patch tested?