Skip to content

Commit

Permalink
[SQL] [MINOR] make star and multialias extend NamedExpression
Browse files Browse the repository at this point in the history
`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 <wangfei1@huawei.com>

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

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

(cherry picked from commit 97d1182)
Signed-off-by: Michael Armbrust <michael@databricks.com>
  • Loading branch information
scwf authored and marmbrus committed May 7, 2015
1 parent 475143a commit 2425e4d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,21 +95,17 @@ 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")
override def exprId: ExprId = throw new UnresolvedException(this, "exprId")
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}")
Expand Down Expand Up @@ -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")

Expand All @@ -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}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

}
Expand Down

0 comments on commit 2425e4d

Please sign in to comment.