Eric5553 commented on a change in pull request #27685: [SPARK-30940][SQL]
Remove attributeId in auto-generated arguments when Explain SQL query
URL: https://github.com/apache/spark/pull/27685#discussion_r389772098
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Expression.scala
##########
@@ -265,14 +265,21 @@ abstract class Expression extends TreeNode[Expression] {
case single => single :: Nil
}
+ protected def flatArgumentStrings: Iterator[String] = flatArguments.map {
+ case e: Expression => e.argumentString
+ case arg => s"$arg"
+ }
+
// Marks this as final, Expression.verboseString should never be called, and
thus shouldn't be
// overridden by concrete classes.
final override def verboseString(maxFields: Int): String =
simpleString(maxFields)
override def simpleString(maxFields: Int): String = toString
override def toString: String = prettyName + truncatedString(
- flatArguments.toSeq, "(", ", ", ")", SQLConf.get.maxToStringFields)
+ flatArgumentStrings.toSeq, "(", ", ", ")", SQLConf.get.maxToStringFields)
+
+ def argumentString: String = toString
Review comment:
IMO, the `argumentString` is needed because `AttributeReference` already
overwrite `toString`, thus we need the new abstract string function to switch
to non-exprid format. For `flatArgumentStrings`, it only have two callers. I
refactored the `toAggString` of `AggregateFunction`, then we don't need to add
the method `flatArgumentStrings` in `Expression` but just implement it within
`toString`. See commit b74c5006a6880773f18507f6b46a1d5674cf7dd4.
----------------------------------------------------------------
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]