edmondop commented on code in PR #853: URL: https://github.com/apache/datafusion-comet/pull/853#discussion_r1724171225
########## spark/src/main/scala/org/apache/spark/Plugins.scala: ########## @@ -44,6 +45,20 @@ class CometDriverPlugin extends DriverPlugin with Logging with ShimCometDriverPl override def init(sc: SparkContext, pluginContext: PluginContext): ju.Map[String, String] = { logInfo("CometDriverPlugin init") + // register CometSparkSessionExtensions if it isn't already registered + val extensionKey = StaticSQLConf.SPARK_SESSION_EXTENSIONS.key + val extensionClass = classOf[CometSparkSessionExtensions].getName + if (sc.conf.contains(extensionKey)) { + val extensions = sc.conf.get(extensionKey) + if (!extensions.split(",").map(_.trim).contains(extensionClass)) { + sc.conf.set(extensionKey, s"$extensions,$extensionClass") + } else { + sc.conf.set(extensionKey, extensionClass) + } + } else { + sc.conf.set(extensionKey, extensionClass) + } Review Comment: I don't have an IDE opened now, but I think this code can be simplified using this overloaded method of get https://spark.apache.org/docs/3.2.1/api/java/org/apache/spark/SparkConf.html#get-java.lang.String-java.lang.String- ```suggestion val extensions = sc.conf.get(extensionKey, "") if (!extensions.split(",").map(_.trim).contains(extensionClass)) { sc.conf.set(extensionKey, s"$extensions,$extensionClass") } else { sc.conf.set(extensionKey, extensionClass) } ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org