Skip to content

Conversation

@cloud-fan
Copy link
Contributor

@cloud-fan cloud-fan commented Oct 20, 2021

What changes were proposed in this pull request?

This PR adds a new internal interface FunctionExpressionBuilder, to replace SessionCatalog.makeFunctionExpression. Then we can put the interface implementation in sql/core, to avoid using reflection in SessionCatalog.makeFunctionExpression, because the class UserDefinedAggregateFunction is not available in sql/catalyst.

Why are the changes needed?

code cleanup, and make it easier to support using Aggregator as UDAF later (#34303).

Does this PR introduce any user-facing change?

no

How was this patch tested?

existing tests

@github-actions github-actions bot added the SQL label Oct 20, 2021
@cloud-fan
Copy link
Contributor Author

cc @viirya @maropu

@SparkQA
Copy link

SparkQA commented Oct 20, 2021

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/48942/

@SparkQA
Copy link

SparkQA commented Oct 20, 2021

Kubernetes integration test status failure
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/48942/

Comment on lines +22 to +25
// A builder to create `Expression` from function information.
trait FunctionExpressionBuilder {
def makeExpression(name: String, clazz: Class[_], input: Seq[Expression]): Expression
}
Copy link
Member

Choose a reason for hiding this comment

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

Should we add a bit more doc about what parameters are, for an interface?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sounds good, @beliefer can you add it in your PR? These 3 parameters were not documented before this PR either.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK

@viirya
Copy link
Member

viirya commented Oct 20, 2021

This looks a good move. Thanks.

@SparkQA
Copy link

SparkQA commented Oct 20, 2021

Test build #144469 has finished for PR 34340 at commit aa472a5.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • trait FunctionExpressionBuilder
  • class SparkUDFExpressionBuilder extends FunctionExpressionBuilder

Copy link
Contributor

@beliefer beliefer left a comment

Choose a reason for hiding this comment

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

This change looks good to me and makes the work about #34303 easy.

@cloud-fan
Copy link
Contributor Author

thanks for the review, merging to master!

@cloud-fan cloud-fan closed this in 32aa114 Oct 21, 2021
yhcast0 pushed a commit to yhcast0/spark that referenced this pull request Apr 5, 2024
…sql/core

This PR adds a new internal interface `FunctionExpressionBuilder`, to replace `SessionCatalog.makeFunctionExpression`. Then we can put the interface implementation in sql/core, to avoid using reflection in `SessionCatalog.makeFunctionExpression`, because the class `UserDefinedAggregateFunction` is not available in sql/catalyst.

code cleanup, and make it easier to support using `Aggregator` as UDAF later (apache#34303).

no

existing tests

Closes apache#34340 from cloud-fan/function.

Authored-by: Wenchen Fan <wenchen@databricks.com>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
// If `super.makeFunctionExpression` throw `InvalidUDFClassException`, we construct
// Hive UDF/UDAF/UDTF with function definition. Otherwise, we just throw it earlier.
case _: InvalidUDFClassException =>
makeHiveFunctionExpression(name, clazz, input)
Copy link

@PengleiShi PengleiShi Sep 14, 2024

Choose a reason for hiding this comment

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

@cloud-fan in prior spark version, it will convert decimal to double when exception occuring, #13930 . At now, some hive udfs which receive double throw UDFArgumentException. The udf extends GenericUDF.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Was it already broken before this PR? The removed code in this PR does not have this handling. Anyway, I'm happy to review the fix if you can create a PR, thanks!

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.

5 participants