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

Auto-register UDF extention when main plugin is set #1102

Merged
merged 3 commits into from
Nov 16, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions sql-plugin/src/main/scala/com/nvidia/spark/rapids/Plugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class SQLExecPlugin extends (SparkSessionExtensions => Unit) with Logging {

object RapidsPluginUtils extends Logging {
private val SQL_PLUGIN_NAME = classOf[SQLExecPlugin].getName
private val UDF_PLUGIN_NAME = "com.nvidia.spark.udf.Plugin"
private val SQL_PLUGIN_CONF_KEY = StaticSQLConf.SPARK_SESSION_EXTENSIONS.key
private val SERIALIZER_CONF_KEY = "spark.serializer"
private val JAVA_SERIALIZER_NAME = classOf[JavaSerializer].getName
Expand All @@ -70,14 +71,16 @@ object RapidsPluginUtils extends Logging {
def fixupConfigs(conf: SparkConf): Unit = {
// First add in the SQL executor plugin because that is what we need at a minimum
if (conf.contains(SQL_PLUGIN_CONF_KEY)) {
val previousValue = conf.get(SQL_PLUGIN_CONF_KEY).split(",").map(_.trim)
if (!previousValue.contains(SQL_PLUGIN_NAME)) {
conf.set(SQL_PLUGIN_CONF_KEY, (previousValue :+ SQL_PLUGIN_NAME).mkString(","))
} else {
conf.set(SQL_PLUGIN_CONF_KEY, previousValue.mkString(","))
for (pluginName <- Array(SQL_PLUGIN_NAME, UDF_PLUGIN_NAME)){
val previousValue = conf.get(SQL_PLUGIN_CONF_KEY).split(",").map(_.trim)
if (!previousValue.contains(pluginName)) {
conf.set(SQL_PLUGIN_CONF_KEY, (previousValue :+ pluginName).mkString(","))
} else {
conf.set(SQL_PLUGIN_CONF_KEY, previousValue.mkString(","))
}
}
} else {
conf.set(SQL_PLUGIN_CONF_KEY, SQL_PLUGIN_NAME)
conf.set(SQL_PLUGIN_CONF_KEY, Array(SQL_PLUGIN_NAME,UDF_PLUGIN_NAME).mkString(","))
}

val serializer = conf.get(SERIALIZER_CONF_KEY, JAVA_SERIALIZER_NAME)
Expand Down