Github user gatorsmile commented on a diff in the pull request:
https://github.com/apache/spark/pull/18966#discussion_r143808338
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeFormatter.scala
---
@@ -89,6 +89,14 @@ object CodeFormatter {
}
new CodeAndComment(code.result().trim(), map)
}
+
+ def stripExtraNewLinesAndComments(input: String): String = {
+ val commentReg =
+ ("""([ |\t]*?\/\*[\s|\S]*?\*\/[ |\t]*?)|""" + // strip /*comment*/
+ """([ |\t]*?\/\/[\s\S]*?\n)""").r // strip //comment
+ val codeWithoutComment = commentReg.replaceAllIn(input, "")
+ codeWithoutComment.replaceAll("""\n\s*\n""", "\n") // strip
ExtraNewLines
+ }
--- End diff --
Could you also add back the test case of this function?
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]