1
votes

Is it possible to reference a datalab object created in one notebook from a different notebook running on the same datalab instance?

Specifically, I would like to reference a big query query constructed using the following syntax:

%%bq query --name myQry
SELECT * FROM etc

In a different notebook to which it was created but I suspect the same answer will apply whether the object in question is a BigQuery query object or not.

I couldn't find anything in the docs

1

1 Answers

1
votes

I found this answer on a similar IPython question.

If you use the %run magic like this:

%run 'theReferencedNotebook.ipynb'

then you can reference all the objects declared in 'theReferenceNotebook.ipynb' (including any bigquery queries) in the new notebook.

For example this cell would get a sample from the myQry query defined on the other notebook:

%%bq sample -q myQry