Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove multiple registration of sim functions #768

Open
wants to merge 2 commits into
base: enterprise
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -10,6 +10,7 @@

public class SparkTransformer extends SparkBaseTransformer {
private static final long serialVersionUID = 1L;
private static boolean udfRegistered = false;

protected SparkSimFunction function;

Expand All @@ -26,7 +27,20 @@ public SparkTransformer(String inputCol, SparkSimFunction function, String outpu


public void register(SparkSession spark) {
spark.udf().register(getUid(), (UDF2) function, DataTypes.DoubleType);
if (!isUDFRegistered(spark, getUid())) {
spark.udf().register(getUid(), (UDF2) function, DataTypes.DoubleType);
udfRegistered = true;
} else {
udfRegistered = true;
}
}

private boolean isUDFRegistered(SparkSession spark, String udfName) {
try {
return spark.catalog().functionExists(udfName);
} catch (Exception e) {
return false; // UDF is not registered
}
}


Expand Down