andygrove opened a new pull request, #4852:
URL: https://github.com/apache/datafusion-comet/pull/4852

   ## Which issue does this PR close?
   
   <!-- No linked issue; opened at user request during a chat about surfacing 
the loaded Comet version. -->
   
   ## Rationale for this change
   
   There is currently no built-in way for a Spark user to programmatically 
query which Comet version is loaded. The JVM `COMET_VERSION` constant exists in 
`org.apache.comet.package` but is only accessible via Scala imports; the native 
library also logs the version on init, but that requires driver log access. 
This PR exposes the version as a plain SQL function so it is reachable from 
PySpark, spark-sql, notebooks, and any other client that can issue SQL — no 
JVM/Scala imports and no log spelunking required.
   
   ## What changes are included in this PR?
   
   - Register a nullary SQL function `comet_version()` via 
`SparkSessionExtensions.injectFunction` in `CometSparkSessionExtensions`. The 
function returns the `COMET_VERSION` string (already populated from 
`comet-git-info.properties` at build time) as a Spark `StringType` literal.
   - Reject any arguments with an `IllegalArgumentException` mentioning the 
function name.
   - Add two unit tests in `CometSparkSessionExtensionsSuite`: one asserting 
`SELECT comet_version()` returns the expected build version, and one asserting 
`comet_version(1)` fails.
   
   Compiles cleanly against `spark-3.4`, `spark-3.5`, `spark-4.0`, and 
`spark-4.1` profiles.
   
   Example usage:
   
   ```
   scala> spark.sql("SELECT comet_version()").show(false)
   +----------------+
   |comet_version() |
   +----------------+
   |1.0.0-SNAPSHOT  |
   +----------------+
   ```
   
   ## How are these changes tested?
   
   - New unit tests in `CometSparkSessionExtensionsSuite` (`comet_version() 
returns the Comet build version` and `comet_version() rejects arguments`).
   - Full suite runs green locally with the `spark-3.5` profile.
   - Verified compilation with `-Pspark-3.4`, `-Pspark-3.5`, and `-Pspark-4.1 
-Pscala-2.13`.


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to