Skip to content
Closed
Show file tree
Hide file tree
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
Prev Previous commit
Next Next commit
update
  • Loading branch information
kiszk committed Jul 27, 2018
commit bfd0509b092f48d075c493b70ba021262edf66af
6 changes: 2 additions & 4 deletions core/src/main/scala/org/apache/spark/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ package object spark {
val resourceStream = Thread.currentThread().getContextClassLoader.
getResourceAsStream("spark-version-info.properties")
if (resourceStream == null) {
// throw new SparkException("Could not find spark-version-info.properties")
throw new SparkException("Could not find spark-version-info.properties")
}

try {
Expand All @@ -74,9 +74,7 @@ package object spark {
)
} catch {
case e: Exception =>
val unknownProp = "<unknown>"
(unknownProp, unknownProp, unknownProp, unknownProp, unknownProp, unknownProp)
// throw new SparkException("Error loading properties from spark-version-info.properties", e)
throw new SparkException("Error loading properties from spark-version-info.properties", e)
} finally {
if (resourceStream != null) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3652,11 +3652,6 @@ case class ArrayDistinct(child: Expression)
* Will become common base class for [[ArrayUnion]], ArrayIntersect, and [[ArrayExcept]].
*/
abstract class ArraySetLike extends BinaryArrayExpressionWithImplicitCast {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shall we extend ComplexTypeMergingExpression here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the question is, shall we apply type coercion rules to these array functions?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure to what level Presto is considered as a reference. Just FYI these operations in Presto can accept arrays of different types.

presto:default> SELECT array_except(ARRAY[5, 1, 7], ARRAY[7.0, 1.0, 3.0]);
 _col0 
-------
 [5.0] 
(1 row)

override def dataType: DataType = {
val dataTypes = children.map(_.dataType.asInstanceOf[ArrayType])
ArrayType(elementType, dataTypes.exists(_.containsNull))
}

override def checkInputDataTypes(): TypeCheckResult = {
val typeCheckResult = super.checkInputDataTypes()
if (typeCheckResult.isSuccess) {
Expand Down Expand Up @@ -3700,7 +3695,8 @@ object ArraySetLike {
array(1, 2, 3, 5)
""",
since = "2.4.0")
case class ArrayUnion(left: Expression, right: Expression) extends ArraySetLike {
case class ArrayUnion(left: Expression, right: Expression) extends ArraySetLike
with ComplexTypeMergingExpression {
var hsInt: OpenHashSet[Int] = _
var hsLong: OpenHashSet[Long] = _

Expand Down Expand Up @@ -3982,6 +3978,10 @@ object ArrayUnion {
""",
since = "2.4.0")
case class ArrayExcept(left: Expression, right: Expression) extends ArraySetLike {
override def dataType: DataType = ArrayType(elementType,
left.dataType.asInstanceOf[ArrayType].containsNull &&
!right.dataType.asInstanceOf[ArrayType].containsNull)

var hsInt: OpenHashSet[Int] = _
var hsLong: OpenHashSet[Long] = _

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1604,8 +1604,9 @@ class CollectionExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper
checkEvaluation(ArrayExcept(aa1, aa0), Seq[Seq[Int]](Seq[Int](2, 1)))

assert(ArrayExcept(a00, a01).dataType.asInstanceOf[ArrayType].containsNull === false)
assert(ArrayExcept(a00, a04).dataType.asInstanceOf[ArrayType].containsNull === true)
assert(ArrayExcept(a04, a02).dataType.asInstanceOf[ArrayType].containsNull === true)
assert(ArrayExcept(a04, a05).dataType.asInstanceOf[ArrayType].containsNull === false)
assert(ArrayExcept(a20, a21).dataType.asInstanceOf[ArrayType].containsNull === false)
assert(ArrayExcept(a20, a24).dataType.asInstanceOf[ArrayType].containsNull === true)
assert(ArrayExcept(a24, a22).dataType.asInstanceOf[ArrayType].containsNull === true)
}
}