diff options
author | Wenchen Fan <wenchen@databricks.com> | 2016-03-21 15:24:18 -0700 |
---|---|---|
committer | Reynold Xin <rxin@databricks.com> | 2016-03-21 15:24:18 -0700 |
commit | f3717fc7c97ea402c9ddf9020405070421eeb4a4 (patch) | |
tree | 59f37eb8ed351e966b7d86ee8584e47e253c401f | |
parent | f35df7d1820738cc1dac81271041707010e2f08f (diff) | |
download | spark-f3717fc7c97ea402c9ddf9020405070421eeb4a4.tar.gz spark-f3717fc7c97ea402c9ddf9020405070421eeb4a4.tar.bz2 spark-f3717fc7c97ea402c9ddf9020405070421eeb4a4.zip |
[SPARK-14004][FOLLOW-UP] Implementations of NonSQLExpression should not override sql method
## What changes were proposed in this pull request?
There is only one exception: `PythonUDF`. However, I don't think the `PythonUDF#` prefix is useful, as we can only create python udf under python context. This PR removes the `PythonUDF#` prefix from `PythonUDF.toString`, so that it doesn't need to overrde `sql`.
## How was this patch tested?
existing tests.
Author: Wenchen Fan <wenchen@databricks.com>
Closes #11859 from cloud-fan/tmp.
-rw-r--r-- | sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Expression.scala | 2 | ||||
-rw-r--r-- | sql/core/src/main/scala/org/apache/spark/sql/execution/python/PythonUDF.scala | 4 |
2 files changed, 2 insertions, 4 deletions
diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Expression.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Expression.scala index 16a1b2aee2..5f8899d599 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Expression.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Expression.scala @@ -226,7 +226,7 @@ trait Unevaluable extends Expression { * `ScalaUDF`, `ScalaUDAF`, and object expressions like `MapObjects` and `Invoke`. */ trait NonSQLExpression extends Expression { - override def sql: String = { + final override def sql: String = { transform { case a: Attribute => new PrettyAttribute(a) }.toString diff --git a/sql/core/src/main/scala/org/apache/spark/sql/execution/python/PythonUDF.scala b/sql/core/src/main/scala/org/apache/spark/sql/execution/python/PythonUDF.scala index 9c3145637d..4f1b837158 100644 --- a/sql/core/src/main/scala/org/apache/spark/sql/execution/python/PythonUDF.scala +++ b/sql/core/src/main/scala/org/apache/spark/sql/execution/python/PythonUDF.scala @@ -32,9 +32,7 @@ case class PythonUDF( children: Seq[Expression]) extends Expression with Unevaluable with NonSQLExpression with Logging { - override def toString: String = s"PythonUDF#$name(${children.mkString(", ")})" + override def toString: String = s"$name(${children.mkString(", ")})" override def nullable: Boolean = true - - override def sql: String = s"$name(${children.mkString(", ")})" } |