You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by ma...@apache.org on 2015/05/08 01:21:31 UTC

spark git commit: [SQL] [MINOR] make star and multialias extend NamedExpression

Repository: spark
Updated Branches:
  refs/heads/master e43803b8f -> 97d1182af


[SQL] [MINOR] make star and multialias extend NamedExpression

`Star` and `MultiAlias` just used in `analyzer` and them will be substituted after analyze,  So just like `Alias` they do not need extend `Attribute`

Author: scwf <wa...@huawei.com>

Closes #5928 from scwf/attribute and squashes the following commits:

73a0560 [scwf] star and multialias do not need extend attribute


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/97d1182a
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/97d1182a
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/97d1182a

Branch: refs/heads/master
Commit: 97d1182af63d55abab44521171652c81c56c6af6
Parents: e43803b
Author: scwf <wa...@huawei.com>
Authored: Thu May 7 16:21:24 2015 -0700
Committer: Michael Armbrust <mi...@databricks.com>
Committed: Thu May 7 16:21:24 2015 -0700

----------------------------------------------------------------------
 .../sql/catalyst/analysis/unresolved.scala      | 20 +++++---------------
 .../catalyst/expressions/namedExpressions.scala |  2 +-
 2 files changed, 6 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/97d1182a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/unresolved.scala
----------------------------------------------------------------------
diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/unresolved.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/unresolved.scala
index 3f567e3..eb736ac 100644
--- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/unresolved.scala
+++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/unresolved.scala
@@ -95,7 +95,7 @@ case class UnresolvedFunction(name: String, children: Seq[Expression]) extends E
  * Represents all of the input attributes to a given relational operator, for example in
  * "SELECT * FROM ...". A [[Star]] gets automatically expanded during analysis.
  */
-trait Star extends Attribute with trees.LeafNode[Expression] {
+trait Star extends NamedExpression with trees.LeafNode[Expression] {
   self: Product =>
 
   override def name: String = throw new UnresolvedException(this, "name")
@@ -103,13 +103,9 @@ trait Star extends Attribute with trees.LeafNode[Expression] {
   override def dataType: DataType = throw new UnresolvedException(this, "dataType")
   override def nullable: Boolean = throw new UnresolvedException(this, "nullable")
   override def qualifiers: Seq[String] = throw new UnresolvedException(this, "qualifiers")
+  override def toAttribute: Attribute = throw new UnresolvedException(this, "toAttribute")
   override lazy val resolved = false
 
-  override def newInstance(): Star = this
-  override def withNullability(newNullability: Boolean): Star = this
-  override def withQualifiers(newQualifiers: Seq[String]): Star = this
-  override def withName(newName: String): Star = this
-
   // Star gets expanded at runtime so we never evaluate a Star.
   override def eval(input: Row = null): EvaluatedType =
     throw new TreeNodeException(this, s"No function to evaluate expression. type: ${this.nodeName}")
@@ -154,7 +150,7 @@ case class UnresolvedStar(table: Option[String]) extends Star {
  * @param names the names to be associated with each output of computing [[child]].
  */
 case class MultiAlias(child: Expression, names: Seq[String])
-  extends Attribute with trees.UnaryNode[Expression] {
+  extends NamedExpression with trees.UnaryNode[Expression] {
 
   override def name: String = throw new UnresolvedException(this, "name")
 
@@ -166,15 +162,9 @@ case class MultiAlias(child: Expression, names: Seq[String])
 
   override def qualifiers: Seq[String] = throw new UnresolvedException(this, "qualifiers")
 
-  override lazy val resolved = false
-
-  override def newInstance(): MultiAlias = this
+  override def toAttribute: Attribute = throw new UnresolvedException(this, "toAttribute")
 
-  override def withNullability(newNullability: Boolean): MultiAlias = this
-
-  override def withQualifiers(newQualifiers: Seq[String]): MultiAlias = this
-
-  override def withName(newName: String): MultiAlias = this
+  override lazy val resolved = false
 
   override def eval(input: Row = null): EvaluatedType =
     throw new TreeNodeException(this, s"No function to evaluate expression. type: ${this.nodeName}")

http://git-wip-us.apache.org/repos/asf/spark/blob/97d1182a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/namedExpressions.scala
----------------------------------------------------------------------
diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/namedExpressions.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/namedExpressions.scala
index 57ace2a..a917058 100644
--- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/namedExpressions.scala
+++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/namedExpressions.scala
@@ -86,7 +86,7 @@ abstract class Attribute extends NamedExpression {
   def withQualifiers(newQualifiers: Seq[String]): Attribute
   def withName(newName: String): Attribute
 
-  def toAttribute: Attribute = this
+  override def toAttribute: Attribute = this
   def newInstance(): Attribute
 
 }


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