cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
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"

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.