maropu commented on a change in pull request #31054:
URL: https://github.com/apache/spark/pull/31054#discussion_r553101861



##########
File path: 
sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkSQLCLIDriver.scala
##########
@@ -530,15 +530,24 @@ private[hive] class SparkSQLCLIDriver extends CliDriver 
with Logging {
     var bracketedCommentLevel = 0
     var escape = false
     var beginIndex = 0
-    var includingStatement = false
+    var leavingBracketedComment = false
+    var isStatement = false
     val ret = new JArrayList[String]
 
     def insideBracketedComment: Boolean = bracketedCommentLevel > 0
     def insideComment: Boolean = insideSimpleComment || insideBracketedComment
-    def statementBegin(index: Int): Boolean = includingStatement || 
(!insideComment &&
+    def statementInProgress(index: Int): Boolean = isStatement || 
(!insideComment &&
       index > beginIndex && !s"${line.charAt(index)}".trim.isEmpty)
 
     for (index <- 0 until line.length) {
+      // judge and reduce bracketed comment level if the flag of leaving  
bracketed comment is true,
+      // because that the last character of bracketed comment is still inside 
the comment and we can
+      // only mark it and reduce bracketed comment level in next loop

Review comment:
       nit: How about rewriting it like this?
   ```
         // Checks if we need to decrement a bracketed comment level; the last 
character '/' of
         // bracketed comments is still inside the comment, so 
`insideBracketedComment` must keep true
         // in the previous loop and we decrement the level here if needed.
   ```
   

##########
File path: 
sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkSQLCLIDriver.scala
##########
@@ -585,7 +594,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
+          leavingBracketedComment = true

Review comment:
       nit:
   ```
   // Decrements `bracketedCommentLevel` at the beginning of the next loop
   leavingBracketedComment = true
   ```




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to