You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "andygrove (via GitHub)" <gi...@apache.org> on 2024/08/20 00:09:11 UTC
[PR] feat: Use CometPlugin as main entrypoint [datafusion-comet]
andygrove opened a new pull request, #853:
URL: https://github.com/apache/datafusion-comet/pull/853
## Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
-->
Closes #.
## Rationale for this change
<!--
Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
-->
## What changes are included in this PR?
<!--
There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
-->
## How are these changes tested?
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
-->
--
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-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] feat: Use CometPlugin as main entrypoint [datafusion-comet]
Posted by "edmondop (via GitHub)" <gi...@apache.org>.
edmondop commented on code in PR #853:
URL: https://github.com/apache/datafusion-comet/pull/853#discussion_r1724172367
##########
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:
The else clause it's also suspicious, are we sure if there are multiple extensions with the key we want to override everything? I suspect the code doesn't need an else branch in reality
--
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-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] feat: Use CometPlugin as main entrypoint [datafusion-comet]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #853:
URL: https://github.com/apache/datafusion-comet/pull/853#issuecomment-2297774354
## [Codecov](https://app.codecov.io/gh/apache/datafusion-comet/pull/853?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
Attention: Patch coverage is `37.50000%` with `5 lines` in your changes missing coverage. Please review.
> Project coverage is 34.06%. Comparing base [(`c9af3f4`)](https://app.codecov.io/gh/apache/datafusion-comet/commit/c9af3f4127ba9f8da8edbb5d6e196fd1359d4f9e?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) to head [(`7befdd0`)](https://app.codecov.io/gh/apache/datafusion-comet/commit/7befdd0310fe91b9e0b7fe501ed8a60bd48cbd37?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
> Report is 3 commits behind head on main.
| [Files](https://app.codecov.io/gh/apache/datafusion-comet/pull/853?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [...park/src/main/scala/org/apache/spark/Plugins.scala](https://app.codecov.io/gh/apache/datafusion-comet/pull/853?src=pr&el=tree&filepath=spark%2Fsrc%2Fmain%2Fscala%2Forg%2Fapache%2Fspark%2FPlugins.scala&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3Bhcmsvc3JjL21haW4vc2NhbGEvb3JnL2FwYWNoZS9zcGFyay9QbHVnaW5zLnNjYWxh) | 37.50% | [4 Missing and 1 partial :warning: ](https://app.codecov.io/gh/apache/datafusion-comet/pull/853?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## main #853 +/- ##
============================================
+ Coverage 34.05% 34.06% +0.01%
+ Complexity 879 860 -19
============================================
Files 112 112
Lines 42959 42958 -1
Branches 9488 9488
============================================
+ Hits 14629 14633 +4
- Misses 25330 25332 +2
+ Partials 3000 2993 -7
```
</details>
[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/datafusion-comet/pull/853?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
--
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-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] feat: Use CometPlugin as main entrypoint [datafusion-comet]
Posted by "comphead (via GitHub)" <gi...@apache.org>.
comphead commented on code in PR #853:
URL: https://github.com/apache/datafusion-comet/pull/853#discussion_r1722609678
##########
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:
its probably would be good to log the overriden value for `spark.sql.extensions` ?
--
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-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] feat: Use CometPlugin as main entrypoint [datafusion-comet]
Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove commented on code in PR #853:
URL: https://github.com/apache/datafusion-comet/pull/853#discussion_r1725109058
##########
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:
Thanks for the review @edmondop. You are correct that the original code was not correct. I have added a unit test and fixed the issue. It is close to your suggestion.
--
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-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] feat: Use CometPlugin as main entrypoint [datafusion-comet]
Posted by "edmondop (via GitHub)" <gi...@apache.org>.
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-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] feat: Use CometPlugin as main entrypoint [datafusion-comet]
Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove merged PR #853:
URL: https://github.com/apache/datafusion-comet/pull/853
--
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-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org