Skip to content
Closed
Prev Previous commit
Next Next commit
Folding Array and Map cases to one, throwing exception for unsupporte…
…d operand's type
  • Loading branch information
MaxGekk committed Jun 20, 2018
commit 431fca84a045744a9f01e7f731df61c2dcf39fe2
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ case class Size(
} else child.dataType match {
case _: ArrayType => value.asInstanceOf[ArrayData].numElements()
case _: MapType => value.asInstanceOf[MapData].numElements()
case other => throw new UnsupportedOperationException(
s"The size function doesn't support the operand type ${other.getClass.getCanonicalName}")
}
}

Expand All @@ -109,8 +111,9 @@ case class Size(
(${childGen.value}).numElements();""", isNull = FalseLiteral)
} else {
child.dataType match {
case _: ArrayType => defineCodeGen(ctx, ev, c => s"($c).numElements()")
case _: MapType => defineCodeGen(ctx, ev, c => s"($c).numElements()")
case _: ArrayType | _: MapType => defineCodeGen(ctx, ev, c => s"($c).numElements()")
case other => throw new UnsupportedOperationException(
Copy link
Member

Choose a reason for hiding this comment

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

Could you reorganize the code? The current flow looks confusing. It appears like that the other types are not supported when legacySizeOfNull is false. However, the input types are already limited to ArrayType and MapType.

s"The size function doesn't support the operand type ${other.getClass.getCanonicalName}")
}
}
}
Expand Down