Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,7 @@ private[hive] class SparkSQLCLIDriver extends CliDriver with Logging {
var bracketedCommentLevel = 0
var escape = false
var beginIndex = 0
var bracketedCommentRightBound = -1
var includingStatement = false
val ret = new JArrayList[String]

Expand All @@ -539,6 +540,10 @@ private[hive] class SparkSQLCLIDriver extends CliDriver with Logging {
index > beginIndex && !s"${line.charAt(index)}".trim.isEmpty)

for (index <- 0 until line.length) {
if (index > 0 && index - 1 == bracketedCommentRightBound) {
bracketedCommentLevel -= 1
}

if (line.charAt(index) == '\'' && !insideComment) {
// take a look to see if it is escaped
// See the comment above about SPARK-31595
Expand Down Expand Up @@ -585,7 +590,7 @@ private[hive] class SparkSQLCLIDriver extends CliDriver with Logging {
if (insideSingleQuote || insideDoubleQuote) {
// Ignores '/' in any case of quotes
} else if (insideBracketedComment && line.charAt(index - 1) == '*' ) {
bracketedCommentLevel -= 1
bracketedCommentRightBound = index
} else if (hasNext && !insideBracketedComment && line.charAt(index + 1) == '*') {
bracketedCommentLevel += 1
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -577,8 +577,8 @@ class CliSuite extends SparkFunSuite with BeforeAndAfterAll with Logging {
"/* SELECT 'test';*/ SELECT 'test';" -> "test",
";;/* SELECT 'test';*/ SELECT 'test';" -> "test",
"/* SELECT 'test';*/;; SELECT 'test';" -> "test",
"SELECT 'test'; -- SELECT 'test';" -> "",
"SELECT 'test'; /* SELECT 'test';*/;" -> "",
"SELECT 'test'; -- SELECT 'test';" -> "test",
"SELECT 'test'; /* SELECT 'test';*/;" -> "test",
"/*$meta chars{^\\;}*/ SELECT 'test';" -> "test",
"/*\nmulti-line\n*/ SELECT 'test';" -> "test",
"/*/* multi-level bracketed*/ SELECT 'test';" -> "test"
Expand Down