Step 1: Add a Parameter Cell

Add a Parameter Cell to the Notebook that you want to call from an other Notebook:

  • Click on the 3 dots and select “Toggle Parameter Cell”
  • Add variables to this cell

Step 2: Use Parameter Cell variables in Notebook

Use the variables from the parameter cell in your next Code Cell(s):

#******************************************************
# Notebook: CleanupTables.ipynb 
#******************************************************

#------------------------------------------------------
# Parameter Cell
#------------------------------------------------------

# input parameters:
prefix= "silver"

#------------------------------------------------------
# Code Cell
#------------------------------------------------------

# List all tables in the current database
tables_df = spark.sql("SHOW TABLES")
tables = [row['tableName'] for row in tables_df.collect()]

# Drop each table
for table_name in tables:
    if( prefix != "" and table_name.startswith( prefix )):
        print(f"Dropping table: {table_name}")
        spark.sql(f"DROP TABLE IF EXISTS {table_name}")

Step 3: Test Parameter Cell

Run the whole Notebook and test the output:

Step 4: Call Notebook with parameter values

Call the Notebook from an other Notebook and pass the Parameter(s)

#******************************************************
# Notebook: Load_Silver_Tables_Sales.ipynb 
#******************************************************

mssparkutils.notebook.run("CleanupTables",90,{"prefix": "silver_sales_"})

# Import tables
# ...

For more information about mssparkutils.notebook.run: Microsoft Spark Utilities