Skip to content

Commit 73a0560

Browse files
committed
star and multialias do not need extend attribute
1 parent c688e3c commit 73a0560

File tree

2 files changed

+6
-16
lines changed

2 files changed

+6
-16
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/unresolved.scala

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -95,21 +95,17 @@ case class UnresolvedFunction(name: String, children: Seq[Expression]) extends E
9595
* Represents all of the input attributes to a given relational operator, for example in
9696
* "SELECT * FROM ...". A [[Star]] gets automatically expanded during analysis.
9797
*/
98-
trait Star extends Attribute with trees.LeafNode[Expression] {
98+
trait Star extends NamedExpression with trees.LeafNode[Expression] {
9999
self: Product =>
100100

101101
override def name: String = throw new UnresolvedException(this, "name")
102102
override def exprId: ExprId = throw new UnresolvedException(this, "exprId")
103103
override def dataType: DataType = throw new UnresolvedException(this, "dataType")
104104
override def nullable: Boolean = throw new UnresolvedException(this, "nullable")
105105
override def qualifiers: Seq[String] = throw new UnresolvedException(this, "qualifiers")
106+
override def toAttribute: Attribute = throw new UnresolvedException(this, "toAttribute")
106107
override lazy val resolved = false
107108

108-
override def newInstance(): Star = this
109-
override def withNullability(newNullability: Boolean): Star = this
110-
override def withQualifiers(newQualifiers: Seq[String]): Star = this
111-
override def withName(newName: String): Star = this
112-
113109
// Star gets expanded at runtime so we never evaluate a Star.
114110
override def eval(input: Row = null): EvaluatedType =
115111
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 {
154150
* @param names the names to be associated with each output of computing [[child]].
155151
*/
156152
case class MultiAlias(child: Expression, names: Seq[String])
157-
extends Attribute with trees.UnaryNode[Expression] {
153+
extends NamedExpression with trees.UnaryNode[Expression] {
158154

159155
override def name: String = throw new UnresolvedException(this, "name")
160156

@@ -166,15 +162,9 @@ case class MultiAlias(child: Expression, names: Seq[String])
166162

167163
override def qualifiers: Seq[String] = throw new UnresolvedException(this, "qualifiers")
168164

169-
override lazy val resolved = false
170-
171-
override def newInstance(): MultiAlias = this
165+
override def toAttribute: Attribute = throw new UnresolvedException(this, "toAttribute")
172166

173-
override def withNullability(newNullability: Boolean): MultiAlias = this
174-
175-
override def withQualifiers(newQualifiers: Seq[String]): MultiAlias = this
176-
177-
override def withName(newName: String): MultiAlias = this
167+
override lazy val resolved = false
178168

179169
override def eval(input: Row = null): EvaluatedType =
180170
throw new TreeNodeException(this, s"No function to evaluate expression. type: ${this.nodeName}")

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/namedExpressions.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ abstract class Attribute extends NamedExpression {
8686
def withQualifiers(newQualifiers: Seq[String]): Attribute
8787
def withName(newName: String): Attribute
8888

89-
def toAttribute: Attribute = this
89+
override def toAttribute: Attribute = this
9090
def newInstance(): Attribute
9191

9292
}

0 commit comments

Comments
 (0)