2

I have a Databricks activity in ADF and I pass the output with the below code:

 dbutils.notebook.exit(message_json)

Now, I want to use this output for the next Databrick activity.

enter image description here

As my search, I think add the last output into base parameters in the second activity. Am I right?

enter image description here

and other questions, How can I use this output inside the Databrick notebook?

Edited: The output is a JSON as the below screenshot.

enter image description here

4
  • What do you exactly mean by output here? Commented Jul 28, 2021 at 11:28
  • @AliHasan I added at end of the question. The output is JSON, as in the above screenshot. I want to load this JSON in the filter notebook. Commented Jul 28, 2021 at 11:40
  • You can do this in databricks, save file in temp table if possible or in dbfs and then again read file in next databricks notebook. As you also have intentions to use this in databricks notebook. Commented Jul 28, 2021 at 11:51
  • @AliHasan I'm looking for a solution using the output of the last activity. Commented Jul 28, 2021 at 20:14

1 Answer 1

3

As per doc, you can consume the output of Databrick Notebook activity in data factory by using expression such as @{activity('databricks notebook activity name').output.runOutput}.

If you are passing JSON object you can retrieve values by appending property names.

Example: @{activity('databricks notebook activity name').output.runOutput.PropertyName}.

I reproduced the issue and it's working fine.

Below is the sample notebook.

import json
dates = ['2017-12-11', '2017-12-10', '2017-12-09', '2017-12-08', '2017-12-07']
return_json = json.dumps(dates)
dbutils.notebook.exit(return_json)

This is how the Notebook2 Activity Seeting looks like: enter image description here

Pipeline ran successfully. enter image description here

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

6 Comments

Thanks for your response and looks great. Other than my question, how can I consume this output to notebook2? Could you share the sample code? for example in notebook2 if the date == '2017-12-10' print yes.
you can use the If Condition activity in ADF and based on True/False can trigger another activity for further process in the pipeline. refer learn.microsoft.com/en-us/azure/data-factory/…
Thanks, I mean use notebook1's output in the body of notebook2. If Condition is a sample operation. I try to clarify my request.
I mean how to use return_json in the body of notebook2?
unable to understand the exact requirement. do you want to write the return_json in notebook2? or want to iterate json objects? or anything else?
|

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.