diff --git a/sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkSQLCLIDriver.scala b/sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkSQLCLIDriver.scala index c506a7d682f32..6b5b412fdaaf1 100644 --- a/sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkSQLCLIDriver.scala +++ b/sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkSQLCLIDriver.scala @@ -600,7 +600,7 @@ private[hive] class SparkSQLCLIDriver extends CliDriver with Logging { } else if (insideBracketedComment && line.charAt(index - 1) == '*' ) { // Decrements `bracketedCommentLevel` at the beginning of the next loop leavingBracketedComment = true - } else if (hasNext && !insideBracketedComment && line.charAt(index + 1) == '*') { + } else if (hasNext && line.charAt(index + 1) == '*') { bracketedCommentLevel += 1 } } diff --git a/sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/CliSuite.scala b/sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/CliSuite.scala index 628167a0a4595..b404d77881137 100644 --- a/sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/CliSuite.scala +++ b/sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/CliSuite.scala @@ -611,4 +611,13 @@ class CliSuite extends SparkFunSuite with BeforeAndAfterAll with Logging { Seq("--conf", s"${BUILTIN_HIVE_VERSION.key}=$builtinHiveVersion"))( s"set ${BUILTIN_HIVE_VERSION.key};" -> builtinHiveVersion, "SET -v;" -> builtinHiveVersion) } + + test("SPARK-37471: spark-sql support nested bracketed comment ") { + runCliWithin(1.minute)( + """ + |/* SELECT /*+ HINT() */ 4; */ + |SELECT 1; + |""".stripMargin -> "SELECT 1" + ) + } }