10-04-2022 02:39 AM
I wish to run a scala command, which I believe would normally be run from a scala command line rather than from within a notebook.
It happens to be:
scala [-cp scalatest-<version>.jar:...] org.scalatest.tools.Runner [arguments]
(scalatest_2.12__3.0.8.jar is included within the databricks runtime)
Can this be run within a scala notebook from databricks, or by some other means within databricks, eg (and ideally) as a job?
I have tried various ways of running this command from within a notebook without success. I'm not sure if its possible or if I need to structure the syntax in such a way for it to work.
Thanks
10-06-2022 01:15 AM
Hi @David Vardy , from notebooks you can try using Scala, ref: https://docs.databricks.com/notebooks/notebooks-use.html#mix-languages.
You can use the language magic command %<language> at the beginning of a cell. The supported magic commands are:
%python
%r
%scala
%sql
10-06-2022 02:57 AM
Hi @Debayan Mukherjee , thanks, I understand I can write Scala scripts in the notebook, which I already do, but I'm not sure how I can run a scala command line command in databricks? For example, using a 7.3 LTS runtime and the following scala in a notebook:
import org.scalatest._
import org.scalatest.tools.Runner
class DBtestSuite extends FeatureSpec with GivenWhenThen {
feature("feature...") {
scenario("scenario...") {
Given("given...")
When("when")
Then("then...")
assert(1==2)
}
}
}
scala -classpath "scalatest_2.12__3.0.8.jar" org.scalatest.tools.Runner -s DBtestSuite
results in error:
error: ';' expected but string literal found.
scala -classpath "scalatest_2.12__3.0.8.jar" org.scalatest.tools.Runner -s DBtestSuite
10-06-2022 06:09 AM
@David Vardy Could you please check if this helps:
https://docs.databricks.com/languages/scala.html
Also, the knowledge base: https://kb.databricks.com/scala/index.html?_ga=2.90545306.1490214985.1664985187-643525343.1663499643
11-02-2022 08:49 PM
Hi @David Vardy
Hope all is well! Just wanted to check in if you were able to resolve your issue and would you be happy to share the solution or mark an answer as best? Else please let us know if you need more help.
We'd love to hear from you.
Thanks!
Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.
If there isn’t a group near you, start one and help create a community that brings people together.
Request a New Group