I've a Jupyter Notebook where i'm trying to import a keys as a string from an outside function. In pyspark all work without problems with this code
Config.py
credentials = {"item1": "prueba"}
def get_key(storage_account):
return credentials[storage_account]
Call in the notebook:
spark.sparkContext.addFile("/home/joaco/data-experiment/notebooks_fpatito/readExternalFilesNotebook/pySpark/Config.py")
import Config
key = Config.get_key("item1")
print(key)
But, when I'm trying to do the same in Scala Spark the notebook throw me a not found error
"not found: value testMap"
testMap.scala
object testMap {
val mapExample = Map(
"item1" -> "item1value",
"item2" -> "item2value",
"item3" -> "item3value",
)
}
I'm doing the same sparkContext.addfile:
spark.sparkContext.addFile("/home/joaco/data-experiment/notebooks_fpatito/readExternalFilesNotebook/Spark/testMap.scala")
And this import: import testMap._
But the class is not found

