Reputation: 163
I have a R notebook in Databricks, that I want to call inside an other R notebook.
I know that to call the notebook_a, one should do :
%run /path/notebook_a
But I want to do it inside an R script. For example :
if(condition){ %run /path/notebook_a }
Of course this code does not work.
Thanks a lot.
Upvotes: 1
Views: 559
Reputation: 87174
You should be able to use dbutils.notebooks.run for calling another notebook, but there is a difference between it and %run
:
dbutils.notebooks.run
executes another notebook as a separate job, so no definitions, etc. is pulled into the context of the current notebook - you can communicated data via temp views, etc.%run
execute another notebook and pulls all definitions and sides effects into the context of the current notebook.I'm not sure if dbutils.notebooks.run
will help in your case.
P.S. I personally would recommend to use %run
with notebooks that only define functions, not doing any calculations, etc. - in this case, even if you have %run
this doesn't cause any side effect on your current context.
Upvotes: 1