Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
cloud-fan committed Jun 1, 2015
1 parent cb77e4f commit 7ae76b9
Show file tree
Hide file tree
Showing 7 changed files with 187 additions and 207 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ trait CheckAnalysis {
val from = operator.inputSet.map(_.name).mkString(", ")
a.failAnalysis(s"cannot resolve '${a.prettyString}' given input columns $from")

case e: Expression if !e.validInputTypes =>
case e: Expression if e.checkInputDataTypes.isDefined =>
e.failAnalysis(
s"cannot resolve '${t.prettyString}' due to data type mismatch: " +
e.typeMismatchErrorMessage.get)
s"cannot resolve '${e.prettyString}' due to data type mismatch: " +
e.checkInputDataTypes.get)

case c: Cast if !c.resolved =>
failAnalysis(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,10 @@ abstract class Expression extends TreeNode[Expression] {
}
}

def typeMismatchErrorMessage: Option[String] = None

def validInputTypes: Boolean = typeMismatchErrorMessage.isEmpty
/**
* todo
*/
def checkInputDataTypes: Option[String] = None
}

abstract class BinaryExpression extends Expression with trees.BinaryNode[Expression] {
Expand All @@ -110,10 +111,6 @@ abstract class LeafExpression extends Expression with trees.LeafNode[Expression]

abstract class UnaryExpression extends Expression with trees.UnaryNode[Expression] {
self: Product =>

override def foldable: Boolean = child.foldable

override def nullable: Boolean = child.nullable
}

// TODO Semantically we probably not need GroupExpression
Expand All @@ -137,5 +134,9 @@ trait ExpectsInputTypes {

def expectedChildTypes: Seq[DataType]

override def validInputTypes: Boolean = children.map(_.dataType) == expectedChildTypes
override def checkInputDataTypes: Option[String] = {
// We will always do type casting for `ExpectsInputTypes` in `HiveTypeCoercion`,
// so type mismatch error won't be reported here, but for underling `Cast`s.
None
}
}
Loading

0 comments on commit 7ae76b9

Please sign in to comment.