Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ trait CheckAnalysis extends PredicateHelper {
// Check if the data types match.
dataTypes(child).zip(ref).zipWithIndex.foreach { case ((dt1, dt2), ci) =>
// SPARK-18058: we shall not care about the nullability of columns
if (dt1.asNullable != dt2.asNullable) {
if (!dt1.sameType(dt2)) {
failAnalysis(
s"""
|${operator.nodeName} can only be performed on tables with the compatible
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ case class If(predicate: Expression, trueValue: Expression, falseValue: Expressi
if (predicate.dataType != BooleanType) {
TypeCheckResult.TypeCheckFailure(
s"type of predicate expression in If should be boolean, not ${predicate.dataType}")
} else if (trueValue.dataType.asNullable != falseValue.dataType.asNullable) {
} else if (!trueValue.dataType.sameType(falseValue.dataType)) {
TypeCheckResult.TypeCheckFailure(s"differing types in '$sql' " +
s"(${trueValue.dataType.simpleString} and ${falseValue.dataType.simpleString}).")
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ abstract class SetOperation(left: LogicalPlan, right: LogicalPlan) extends Binar
childrenResolved &&
left.output.length == right.output.length &&
left.output.zip(right.output).forall { case (l, r) =>
l.dataType.asNullable == r.dataType.asNullable
l.dataType.sameType(r.dataType)
} && duplicateResolved
}

Expand Down Expand Up @@ -211,8 +211,8 @@ case class Union(children: Seq[LogicalPlan]) extends LogicalPlan {
child.output.length == children.head.output.length &&
// compare the data types with the first child
child.output.zip(children.head.output).forall {
case (l, r) => l.dataType.asNullable == r.dataType.asNullable }
)
case (l, r) => l.dataType.sameType(r.dataType)
})
children.length > 1 && childrenResolved && allChildrenCompatible
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ case class DataSourceAnalysis(conf: CatalystConf) extends Rule[LogicalPlan] {

case i @ logical.InsertIntoTable(
l @ LogicalRelation(t: HadoopFsRelation, _, table), part, query, overwrite, false)
if query.resolved && t.schema.asNullable == query.schema.asNullable =>
if query.resolved && t.schema.sameType(query.schema) =>

// Sanity checks
if (t.location.rootPaths.size != 1) {
Expand Down