Skip to content

Conversation

@panbingkun
Copy link
Contributor

What changes were proposed in this pull request?

Why are the changes needed?

Does this PR introduce any user-facing change?

How was this patch tested?

Was this patch authored or co-authored using generative AI tooling?

@github-actions github-actions bot added the SQL label Jul 3, 2024
@panbingkun panbingkun changed the title [Only Test] Make HiveGenericUDF lazy [Only Test] Make HiveGenericUDF's DeferredObject lazy Jul 3, 2024

def setArg(index: Int, arg: Any): Unit =
deferredObjects(index).asInstanceOf[DeferredObjectAdapter].set(arg)
deferredObjects(index).asInstanceOf[DeferredObjectAdapter].set(() => arg)
Copy link
Contributor

Choose a reason for hiding this comment

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

cc @jackylee-ch Can you test this fix?

Copy link
Contributor

Choose a reason for hiding this comment

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

cc @jackylee-ch Can you test this fix?

I have some change in my local. Like @cloud-fan said, we should pass function to setArg to make it lazy. I have passed the failed case with none codegen case, and I'm still trying to fix it with codegen.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jackylee-ch Can you help test the updated version again?
Thanks.


override def returnType: DataType = inspectorToDataType(returnInspector)

def setArg(index: Int, arg: Any): Unit =
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 we should make it lazy at the very beginning, arg here is already materialized.

| return $finalEval;
| }
| };
|$refEvaluator.setFuncArg($i, $funcArg);
Copy link
Contributor

@jackylee-ch jackylee-ch Jul 3, 2024

Choose a reason for hiding this comment

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

This won't work as we should mv the eval.code in apply, so that we can lazy run child functions. Just like the following code.

          |$refEvaluator.setArg($i, new scala.runtime.AbstractFunction0<Object>() {
          |  public Object apply() {
          |    ${eval.code}
          |    return ${eval.value};
          |  }
          |});
          """.stripMargin

@panbingkun panbingkun closed this Jul 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants