cloud-fan commented on a change in pull request #28420:
URL: https://github.com/apache/spark/pull/28420#discussion_r420659008
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Expression.scala
##########
@@ -323,6 +324,18 @@ 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("(", ", ", ")")
Review comment:
another idea: maybe we can define a `mkString` method?
```
def exprsReplaced: Seq[Expression]
def mkString(childrenString: Seq[String]): String =
childrenString.mkString("(", ", ", ")")
override def sql: String = prettyName + mkString(exprsReplaced.map(_.sql))
```
then in `util`
```
case r: RuntimeReplaceable =>
PrettyAttribute(r.mkString(r.exprsReplaced.map(toPrettySQL)), r.dataType)
```
----------------------------------------------------------------
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]