- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2015 01:26 PM
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2015 05:16 PM
@kruhly Unfortunately right now you can't pass specific variable names, only constants. It's on our roadmap to improve/overhaul parameter passing, which would include this capability.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2015 01:26 PM
Executing NotebookB from NotebookA with arguments, you would use the following syntax within NotebookA to define the arguments:
%run path/to/NotebookB $VarA="ValueA" $VarB="ValueB"
Within NotebookB, you'd use the following to receive the argument value:
Scala and Python:
print getArgument("VariableName", "DefaultValue")
SQL (No default value is supported):
select * from $VariableName
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2015 12:06 PM
should'nt the SQL be
select * from $VarA
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2015 04:11 PM
Is there a way to pass a variable's value from another cell to NotebookB? For example,
----Cell1------------------------
john = 10
-----Cell2--------------------
%run path/to/NotebookB $VarA = john
submits "john" to NotebookB not the value of 10
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2015 05:16 PM
@kruhly Unfortunately right now you can't pass specific variable names, only constants. It's on our roadmap to improve/overhaul parameter passing, which would include this capability.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2023 04:47 PM
where there any updates in this regard?
it's been 1.5 years, so i'm hoping this capability was added by now.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2023 03:57 AM
Looks like this feature is still not available. is there any plan to pass parameter values from another cell when running the notebook via %run?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2023 09:00 AM
Using dbutils.notebook api helped with this. The command follows this syntax:
dbutils.notebook.run("notebook", "timeout_secounds", {"widget_value": " "})
To get a variable in there just do this:
x = "value"
dbutils.notebook.run("run_weekly_notebook", 60, {"stores_available": f"{x}"})
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2015 08:47 AM
Is there any plan to support default argument values for SQL?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2016 05:42 AM
@Databricks_Support, When I try the above, first %run tells me it cannot find the notebook (albeit they are in the same folder. I do not know how to set path\to\notebook right). Second, the getArgument gives me an error
py4j.Py4JException: Method createTextWidget([class java.lang.String, class java.lang.Integer, null, null]) does not exist
. I am using Python notebooks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2016 04:51 AM
Is there any similir functionality for an R notebook?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2016 03:49 PM
@Oren Benjamin you can use a UDF in SQL and then, in the UDF's code, you can use the Scala/Python form.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2018 10:24 PM
If you are running a notebook from another notebook, then use dbutils.notebook.run(path = " ", args={}, timeout='120'), you can pass variables in args = {}. And you will use dbutils.widget.get() in the notebook to receive the variable.
And if you are not running a notebook from another notebook, and just want to a variable before running particular cell in the notebook, use dbutils.widget.text("a","b","c") and dbutils.widget.get().
dbutils.widget.text("a","b","c") :Set the value; a,b,c are mandatory, a : name of the variable, b : default value, c : name of the textbox
dbutils.widget.get(): Assign the value to variable, I am not sure about the arguments here, look it up.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2022 09:43 AM
Hello, is there already a solution to this problem?
I have found a workaround for my use case. Hovewer, the workaround seems to have a databricks failure since without using the if statement the %run code is working and with if - an error is displayed as can be seen in the screenshot.
I am very interested in a solution!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2023 06:49 AM
This info also needed to me as well