Skip to content

Commit

Permalink
move metadata from Expr to NamedExpr
Browse files Browse the repository at this point in the history
  • Loading branch information
mengxr committed Oct 21, 2014
1 parent ddfcfad commit 611d3c2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ abstract class Expression extends TreeNode[Expression] {
def nullable: Boolean
def references: AttributeSet = AttributeSet(children.flatMap(_.references.iterator))

/** Returns the metadata when an expression is a reference to another expression with metadata. */
def metadata: Metadata = Metadata.empty

/** Returns the result of evaluating this expression on a given input Row */
def eval(input: Row = null): EvaluatedType

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ abstract class NamedExpression extends Expression {

def toAttribute: Attribute

/** Returns the metadata when an expression is a reference to another expression with metadata. */
def metadata: Metadata = Metadata.empty

protected def typeSuffix =
if (resolved) {
dataType match {
Expand Down Expand Up @@ -89,11 +92,16 @@ case class Alias(child: Expression, name: String)

override def dataType = child.dataType
override def nullable = child.nullable
override def metadata: Metadata = child.metadata
override def metadata: Metadata = {
child match {
case named: NamedExpression => named.metadata
case _ => Metadata.empty
}
}

override def toAttribute = {
if (resolved) {
AttributeReference(name, child.dataType, child.nullable, child.metadata)(exprId, qualifiers)
AttributeReference(name, child.dataType, child.nullable, metadata)(exprId, qualifiers)
} else {
UnresolvedAttribute(name)
}
Expand Down

0 comments on commit 611d3c2

Please sign in to comment.