Export & Import Databricks
Introduction
In our previous blog, we explained how we can create a notebook and execute some basic Spark queries and how we can write data into the DBFS and thereby, make it persistent. But suppose you decide that you want to pass this particular notebook to another person or make changes in it yourself? Greetings to the new blog where I will explain how you can export and import Databricks notebooks.
Why Export and Import Notebooks?
The notebook that we developed here is solely confined to our reporting and to our account only and if we wish to provide it to someone, then it has to be exported from our system to then provided to them. They can then move it and upload it into their Databricks account.
Exporting a Notebook
To export a notebook, one has to navigate to the specific workspace of the notebook that they want to export. One can do this using the right-click button then click “Export” or one can go to the three dots button then click on “Export”. These formats will be available to you and include; DBC archive, source file, HTML, and Python. Here in this blog, let me choose the DBC archive.
Downloading the Notebook
When you click on export option the downloading will start and the notebook will be downloaded into your system as a .dbc file.
Importing a Notebook
Now, let’s go through how to import the notebook to a new Databricks account. This can be done directly in the workspace where one needs to right-click and there options that allows for import of features. Select the “Import” tab and then from the options choose “File”. Run the mouse to the directory containing the .dbc, If the file is available, it will be highlighted; you should only click on the “Import” button.
After some time, the import will be done, and you realize that all the queries up to the results are there in the notebook. This means that the queries and/or their result/answer has remained the same even when we exported this notebook and then imported the same.
Something to note is that if you export the notebook and another person imports it into their Databricks account they will have to first create the folder directory and then upload all the datasets in each of the file folders. They will also have to edit the path in all the queries where we included the path of the folder.
Conclusion
And that’s all the content with which we have equipped this blog! You know how to export and import Databricks notebooks. It also lets you to freely share NIC notebooks to third parties so that you can more easily collaborate on projects.