vanzin commented on a change in pull request #23169: [SPARK-26103][SQL] Limit
the length of debug strings for query plans
URL: https://github.com/apache/spark/pull/23169#discussion_r264353264
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/StringUtils.scala
##########
@@ -114,9 +127,33 @@ object StringUtils {
* returns concatenated string.
*/
override def toString: String = {
- val result = new java.lang.StringBuilder(length)
+ val finalLength = if (atLimit) maxLength else length
+ val result = new java.lang.StringBuilder(finalLength)
strings.foreach(result.append)
result.toString
}
}
+
+ /**
+ * A string concatenator for plan strings. Uses length from a configured
value, and
+ * prints a warning the first time a plan is truncated.
+ */
+ class PlanStringConcat extends StringConcat(Math.max(0,
SQLConf.get.maxPlanStringLength - 30)) {
+ override def toString: String = {
+ if (atLimit) {
+ logWarning(
+ "Truncated the string representation of a plan since it was too
long. The " +
+ s"plan had length ${length} and the maximum is ${maxLength}. This
behavior " +
+ "can be adjusted by setting
'${SQLConf.MAX_PLAN_STRING_LENGTH.key}'.")
+ val truncateMsg = s"... ${length - maxLength} more characters"
+ val result = new java.lang.StringBuilder(maxLength +
truncateMsg.length)
+ strings.foreach(result.append)
+ result.append(truncateMsg)
+ result.toString
+ }
+ else {
Review comment:
move to previous line
----------------------------------------------------------------
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]