Forum Discussion

smpa01's avatar
smpa01
Community Champion
2 years ago

Mounting NB on- the-fly

I am running some codes in a standalone notebook that is currently giving me the following error

Spark SQL queries are only possible in the context of a lakehouse. Please attach a lakehouse to proceed

 

How can I progrmaatically mount/add a lakehouse to a NB prior to execution of that code. I tried following

notebookutils.fs.mount('abfss://[email protected]/lh_id','/lakehouse/default')

and then I tried running the spark code which still gave me the same error as above.

 

Is it doable?

 

10 Replies

    • smpa01's avatar
      smpa01
      Community Champion

      This post describes how to mount a NB which is exactly similar to what I have provided (good so far)

      but it does not execute a code in a Notebook manually attached to a Lakehouse would have successfully executed otherwise.

       

      The objective of progrmatic mounting is to see if the succedding code executes correctly as it would have in a manually attached lakehouse.

      • frithjof_v's avatar
        frithjof_v
        Community Champion

        I see, I will do a test on my side if I find the time to do the test.

         

        Btw I see you are using notebookutils whereas the blog post is using mssparkutils.

         

        Will it work if you use mssparkutils instead of notebookutils?