Github user rxin commented on a diff in the pull request:
https://github.com/apache/spark/pull/12044#discussion_r57806315
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeFormatter.scala
---
@@ -43,15 +43,41 @@ object CodeFormatter {
private class CodeFormatter {
private val code = new StringBuilder
- private var indentLevel = 0
private val indentSize = 2
+
+ // Tracks the level of indentation in the current line.
+ private var indentLevel = 0
private var indentString = ""
private var currentLine = 1
+ // Tracks the level of indentation in multi-line comment blocks.
+ private var inCommentBlock = false
+ private var indentLevelOutsideCommentBlock = indentLevel
+
private def addLine(line: String): Unit = {
- val indentChange =
- line.count(c => "({".indexOf(c) >= 0) - line.count(c =>
")}".indexOf(c) >= 0)
- val newIndentLevel = math.max(0, indentLevel + indentChange)
+
+ val indentChange = line.count(c => "({".indexOf(c) >= 0) -
line.count(c => ")}".indexOf(c) >= 0)
--- End diff --
add some comment saying this is not the most robust implementation but
should work for the cases we have for generated code
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]