Forum Discussion
Fabric Notebook ExitValue how to select specific values
- 6 months ago
Hi Ka13 ,
Yes we can read this query in a copy activity. First convert this select query to json
import jsonfrom notebookutils import notebooknb_result = {"select_query": select_query}notebook.exit(json.dumps(nb_result))Then in pipeline add notebook activity and connect to copy data. In the dynamic content of copy data, add this json expression.
@json(activity('Notebook1').output.exitValue).select_queryThis works.
If this post helps, please accept this as a solution. Appreciate your kudos.
Thanks,
Pallavi_r
Hi Ka13 ,
The exitvalue returned from mssparkutils.notebook.run() is always a string. We need to first parse into json using function - json.loads to access its element. Please see the below code.
|
import json
parsed = json.loads(exit_value)
schema = parsed["parent1"]["Details"]["schema"]
table = parsed["parent1"]["Details"]["table"]
|
The above code worked for me. Please see and let me know if it resolves this issue.
If this post helps, please accept this as a solution. Appreciate your kudos.
Thanks,
Pallavi_r
- Ka137 months agoHelper II
Thanks Pallavi for your reply.
Can we pass the above ExitValue from one notebook to another Notebook activity and access the values of schema and table in another Notebook?. Can you please suggest
- pallavi_r7 months agoSuper User
Hi Ka13
Yes definitely. Please see this. Below code is written in 2nd notebook calling another notebook.
exit_value = mssparkutils.notebook.run("nb_begin",timeout_seconds=60)If this post helps, please accept this as a solution. Appreciate your kudos.
Thanks,
Pallavi
- Ka137 months agoHelper II
Thanks Pallavi, in Details if we have one more field of columns like - id,name,city,country. And to extract columns.
can you please suggest.