Home > Software engineering >  Unable to call Notebook when using scala code in Databricks
Unable to call Notebook when using scala code in Databricks

Time:01-06

I am into a situation where I am able to successfully run the below snippet in azure Databricks from a separate CMD.

%run ./HSCModule

But running into issues when including that piece of code with other scala code which is importing below packages and getting following error.

import java.io.{File, FileInputStream} 
import java.text.SimpleDateFormat 
import java.util{Calendar, Properties} 
import org.apache.spark.SparkException
import org.apache.spark.sql.SparkSession 
import scala.collection.JavaConverters._
import scala.util._

ERROR = :168: error: ';' expected but '.' found. %run ./HSCModule

FYI - I have also used dbutils.notebook.run and still facing same issues.

CodePudding user response:

You can't mix the magic commands, like, %run, %pip, etc. with the Scala/Python code in the same cell. Documentation says:

%run must be in a cell by itself, because it runs the entire notebook inline.

So you need to put this magic command into a separate cell.

  •  Tags:  
  • Related