cloud-fan commented on a change in pull request #28420:
URL: https://github.com/apache/spark/pull/28420#discussion_r419953260



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Expression.scala
##########
@@ -323,6 +324,20 @@ trait RuntimeReplaceable extends UnaryExpression with 
Unevaluable {
   // two `RuntimeReplaceable` are considered to be semantically equal if their 
"child" expressions
   // are semantically equal.
   override lazy val canonicalized: Expression = child.canonicalized
+
+  /**
+   * Only used to generate SQL representation of this expression.
+   *
+   * Implementations should override this with original parameters
+   */
+  protected def exprsReplaced: Seq[Expression]
+
+  override def sql: String = prettyName + 
exprsReplaced.map(_.sql).mkString("(", ", ", ")")
+
+  protected def prettySQL: String =
+    prettyName + exprsReplaced.map(toPrettySQL).mkString("(", ", ", ")")
+
+  def asPrettyAttribute(): PrettyAttribute = PrettyAttribute(prettySQL, 
dataType)

Review comment:
       why not add a `def withPrettyAttributes: this.type`? The current way 
requires fewer changes as we can have a default implementation, but it's hacky 
to convert `RuntimeReplaceable` to a single `PrettyAttribute`.




----------------------------------------------------------------
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:
us...@infra.apache.org



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

Reply via email to