You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "MaxGekk (via GitHub)" <gi...@apache.org> on 2025/01/25 09:18:02 UTC

Re: [PR] [SPARK-50558][SQL] Introduce simpleString for ExpressionSet [spark]

MaxGekk commented on code in PR #49650:
URL: https://github.com/apache/spark/pull/49650#discussion_r1929509932


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/ExpressionSet.scala:
##########
@@ -178,5 +180,12 @@ class ExpressionSet protected(
        |baseSet: ${baseSet.mkString(", ")}
        |originals: ${originals.mkString(", ")}
      """.stripMargin
+
+  /** Returns a length limited string that must be used for logging only. */
+  def simpleString(maxFields: Int): String = {
+    val customToString = { e: Expression => e.simpleString(maxFields) }
+    s"Set(${SparkStringUtils.truncatedString(
+      seq = originals.toSeq, start = "", sep = ", ", end = "", maxFields, Some(customToString))})"

Review Comment:
   Just set `start = "Set("`, and `end = ")"`



##########
sql/api/src/main/scala/org/apache/spark/sql/catalyst/util/StringUtils.scala:
##########
@@ -94,7 +95,11 @@ object SparkStringUtils extends Logging {
       val restNum = seq.length - numFields
       val ending = (if (numFields == 0) "" else sep) +
         (if (restNum == 0) "" else s"... $restNum more fields") + end
-      seq.take(numFields).mkString(start, sep, ending)
+      if (customToString.isDefined) {
+        seq.take(numFields).map(customToString.get).mkString(start, sep, ending)
+      } else {
+        seq.take(numFields).mkString(start, sep, ending)
+      }
     } else {
       seq.mkString(start, sep, end)

Review Comment:
   How about applying the custom converter here?



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org