Skip to content
Closed
Changes from 1 commit
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
Next Next commit
[SPARK-17108][SQL]: Fix BIGINT and INT comparison failure in spark sql
  • Loading branch information
weiqingy committed Oct 12, 2016
commit ec3d55296abc9f355a0f0db0f40e04abb4b58d94
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,17 @@ abstract class DataType extends AbstractDataType {
private[spark] def sameType(other: DataType): Boolean =
DataType.equalsIgnoreNullability(this, other)

/**
* Check if two integers are compatible. Returns true if `right` can be converted to `left`.
*/
private[spark] def isCompatibleIntegralType(left: DataType, right: DataType): Boolean = {
(left, right) match {
case (l, r) => l.isInstanceOf[IntegralType] && r.isInstanceOf[IntegralType] &&
l.defaultSize >= r.defaultSize
case _ => false
}
}

/**
* Returns the same data type but set all nullability fields are true
* (`StructField.nullable`, `ArrayType.containsNull`, and `MapType.valueContainsNull`).
Expand All @@ -91,7 +102,8 @@ abstract class DataType extends AbstractDataType {

override private[sql] def defaultConcreteType: DataType = this

override private[sql] def acceptsType(other: DataType): Boolean = sameType(other)
override private[sql] def acceptsType(other: DataType): Boolean = sameType(other) ||
isCompatibleIntegralType(this, other)
}


Expand Down