1

I have a SQL notebook(notebookA) where I want to pass arguments from another notebook(notebookB).

---notebookA---
SELECT $v as $c

When I do this from notebook B, it is giving me result.

---notebookB---
%run ./notebookA $v='james' $c=name

enter image description here

But when there is a space in value it is giving me error like below

---notebookB---
%run ./notebookA $v='james potter' $c=name

Failed to parse %run command: string matching regex `\$[\w_]+' expected but `p' found)

What would be the solution then?

1 Answer 1

1

Magic commands do not allow variables to be passed. Instead you can use dbutils.

Python:

dbutils.notebook.run("notebookA", 60, {"v": "james potter", "c": name})

Reference: https://docs.databricks.com/user-guide/notebooks/notebook-workflows.html

Sign up to request clarification or add additional context in comments.

1 Comment

magic commands do allow variable to pass. You can see that from my first example. I am getting error when there is a space in value. Also I think "c":name} will give me an error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.