cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

Run Query from another notebook in streaming job

deng_dev
New Contributor III

Hi!
We want to run query located in another notebook every streaming microbatch.
We were trying dbutils.run.notebook but we always get error

Context not valid. If you are calling this outside the main thread, you must set the Notebook context via dbutils.notebook.setContext(ctx), where ctx is a value retrieved from the main thread (and the same cell) via dbutils.notebook.getContext().

We tried to do what is mentioned in command, but it still doesn't seem to work.
We decided to test using old command execution API, but I am not able to get the status of command using 

/api/1.2/commands/status as it always fails with error:

 

'error_code': 'INVALID_PARAMETER_VALUE', 'message': 'Cluster id cannot be null', 'error': 'DatabricksServiceException: INVALID_PARAMETER_VALUE: Cluster id cannot be null'

 

however I am providing cluster id.
Maybe there are other options of running query from external notebook?

1 REPLY 1

norbitek
New Contributor II

Query Parameters means that you have to pass all parameters as a part of URL after question mark not in the body

"/api/1.2/commands/status?clusterId=$cid&contextId=$ec_id&commandId=$command_id"

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group