Skip to content

Commit

Permalink
avoid constant udf expression re-evaluation
Browse files Browse the repository at this point in the history
- fixes failure due to return iterator and value type mismatch
  • Loading branch information
gvramana committed Nov 23, 2014
1 parent c46db0f commit a18f917
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ private[hive] case class HiveGenericUdf(functionClassName: String, children: Seq
override def foldable =
isUDFDeterministic && returnInspector.isInstanceOf[ConstantObjectInspector]

@transient
protected lazy val constantReturnValue = unwrap(
returnInspector.asInstanceOf[ConstantObjectInspector].getWritableConstantValue(),
returnInspector)

@transient
protected lazy val deferedObjects =
argumentInspectors.map(new DeferredObjectAdapter(_)).toArray[DeferredObject]
Expand All @@ -172,6 +177,8 @@ private[hive] case class HiveGenericUdf(functionClassName: String, children: Seq

override def eval(input: Row): Any = {
returnInspector // Make sure initialized.
if(foldable) return constantReturnValue

var i = 0
while (i < children.length) {
val idx = i
Expand Down

0 comments on commit a18f917

Please sign in to comment.