Skip to content

Commit 7ae76b9

Browse files
committed
address comments
1 parent cb77e4f commit 7ae76b9

File tree

7 files changed

+187
-207
lines changed

7 files changed

+187
-207
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ trait CheckAnalysis {
6262
val from = operator.inputSet.map(_.name).mkString(", ")
6363
a.failAnalysis(s"cannot resolve '${a.prettyString}' given input columns $from")
6464

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

7070
case c: Cast if !c.resolved =>
7171
failAnalysis(

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,10 @@ abstract class Expression extends TreeNode[Expression] {
8787
}
8888
}
8989

90-
def typeMismatchErrorMessage: Option[String] = None
91-
92-
def validInputTypes: Boolean = typeMismatchErrorMessage.isEmpty
90+
/**
91+
* todo
92+
*/
93+
def checkInputDataTypes: Option[String] = None
9394
}
9495

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

111112
abstract class UnaryExpression extends Expression with trees.UnaryNode[Expression] {
112113
self: Product =>
113-
114-
override def foldable: Boolean = child.foldable
115-
116-
override def nullable: Boolean = child.nullable
117114
}
118115

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

138135
def expectedChildTypes: Seq[DataType]
139136

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

0 commit comments

Comments
 (0)