beliefer commented on a change in pull request #27481:
[SPARK-30758][SQL][TESTS] Improve bracketed comments tests.
URL: https://github.com/apache/spark/pull/27481#discussion_r378221686
##########
File path: sql/core/src/test/scala/org/apache/spark/sql/SQLQueryTestSuite.scala
##########
@@ -261,10 +271,37 @@ class SQLQueryTestSuite extends QueryTest with
SharedSparkSession {
}
}.flatten
+ val tempQueries = if (code.exists(_.trim.startsWith("--QUERY-DELIMITER")))
{
+ // Although the loop is heavy, only used for comments test.
+ val querys = new ArrayBuffer[String]
+ val otherCodes = new ArrayBuffer[String]
+ var tempStr = ""
+ var start = false
+ for (c <- code) {
+ if (c.trim.startsWith("--QUERY-DELIMITER-START")) {
+ start = true
+ querys ++= otherCodes.toSeq.mkString("\n").split("(?<=[^\\\\]);")
+ otherCodes.clear()
+ } else if (c.trim.startsWith("--QUERY-DELIMITER-END")) {
+ start = false
+ if (tempStr.endsWith(";")) {
+ tempStr = tempStr.substring(0, tempStr.length - 1)
+ }
+ querys += s"\n$tempStr"
+ tempStr = ""
+ } else if (start) {
+ tempStr += s"\n$c"
+ } else {
+ otherCodes += c
+ }
+ }
+ querys.toSeq
Review comment:
OK. I forgot it.
----------------------------------------------------------------
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]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]